#include <iostream> #include <fstream> #include <iomanip> //include function libraries using namespace std; int main() { //declares all variables string student, Address, phone, Years, ssn; int Age; double testone,testtwo, testthree, testfour, FinalExam, Average; char lettergrade; //declares ifstream and ofstream objects ifstream inputfile; ofstream outputfile; //opens the txt files that the information will be taken from and written too. inputfile.open("studentdata.txt"); outputfile.open("studentdataoutput.txt"); //set precision outputfile<<fixed<< setprecision(2); //allows the computer to skip over whitespace in the file // to read name properly getline(inputfile, student); //continues to read the variables from the .txt file inputfile>> Age; inputfile.ignore(); getline(inputfile, Address); inputfile >> Years; inputfile >> phone; inputfile >> ssn; inputfile >> testone; inputfile >> testtwo; inputfile >>testthree; inputfile >>testfour; inputfile >> FinalExam; //the program is outputting all the information to the text file //setw to align all the items outputfile <<setw(45)<< "Student Grade Sheet" << endl; outputfile <<setw(35)<<"Name of Student:" << " " <<student << endl; outputfile <<setw(35)<< "Age:" << " " <<Age << endl; outputfile <<setw(35)<< "Address:" << " " << Address <<endl; outputfile <<setw(35)<< "Number of years at Texas State:" << " " << Years<<endl; outputfile <<setw(35)<< "Telephone Number:" << " " << phone<< endl; outputfile <<setw(35)<< "Student Social Security #:" << " " << ssn<<endl; outputfile <<setw(35)<< "Test #1:" << " outputfile <<setw(35)<< "Test #2:" << " outputfile <<setw(35)<< "Test #3:" << " outputfile <<setw(35)<< "Test #4:" << " outputfile <<setw(35)<< "Final Exam:" << " //calculates the average of all exams " << testone<<endl; " << testtwo<< endl; " <<testthree<<endl; " <<testfour<<endl; " << FinalExam<<endl; Average=(testone*.1)+(testtwo*.15)+(testthree*.15)+(testfour*.20)+(FinalExam*.40); // if and else statements to convert the average to a letter grade // if (Average < 60) { lettergrade = 'F'; } else if (Average < 70) { lettergrade = 'D'; } else if (Average < 80) { lettergrade = 'C'; } else if (Average < 90) { lettergrade = 'B'; } else { lettergrade = 'A'; } outputfile << setw(35)<< "Your letter grade is: " << lettergrade << endl; // closes both files that were read from and written too inputfile.close(); outputfile.close(); //returns control to the operating system return 0; }
Standard input is empty
prog.cpp:63:39: warning: missing terminating " character [enabled by default] outputfile <<setw(35)<< "Test #1:" << " ^ prog.cpp:63:1: error: missing terminating " character outputfile <<setw(35)<< "Test #1:" << " ^ prog.cpp:64:39: warning: missing terminating " character [enabled by default] outputfile <<setw(35)<< "Test #2:" << " ^ prog.cpp:64:1: error: missing terminating " character outputfile <<setw(35)<< "Test #2:" << " ^ prog.cpp:65:39: warning: missing terminating " character [enabled by default] outputfile <<setw(35)<< "Test #3:" << " ^ prog.cpp:65:1: error: missing terminating " character outputfile <<setw(35)<< "Test #3:" << " ^ prog.cpp:66:39: warning: missing terminating " character [enabled by default] outputfile <<setw(35)<< "Test #4:" << " ^ prog.cpp:66:1: error: missing terminating " character outputfile <<setw(35)<< "Test #4:" << " ^ prog.cpp:67:42: warning: missing terminating " character [enabled by default] outputfile <<setw(35)<< "Final Exam:" << " ^ prog.cpp:67:1: error: missing terminating " character outputfile <<setw(35)<< "Final Exam:" << " ^ prog.cpp:70:1: warning: missing terminating " character [enabled by default] " << testone<<endl; ^ prog.cpp:70:1: error: missing terminating " character prog.cpp:71:1: warning: missing terminating " character [enabled by default] " << testtwo<< endl; ^ prog.cpp:71:1: error: missing terminating " character prog.cpp:72:1: warning: missing terminating " character [enabled by default] " <<testthree<<endl; ^ prog.cpp:72:1: error: missing terminating " character prog.cpp:73:1: warning: missing terminating " character [enabled by default] " <<testfour<<endl; ^ prog.cpp:73:1: error: missing terminating " character prog.cpp:74:4: warning: missing terminating " character [enabled by default] " << FinalExam<<endl; ^ prog.cpp:74:4: error: missing terminating " character prog.cpp: In function ‘int main()’: prog.cpp:75:8: error: no match for ‘operator=’ (operand types are ‘std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}’ and ‘double’) Average=(testone*.1)+(testtwo*.15)+(testthree*.15)+(testfour*.20)+(FinalExam*.40); ^ prog.cpp:75:8: note: candidate is: In file included from /usr/include/c++/4.8/iostream:39:0, from prog.cpp:1: /usr/include/c++/4.8/ostream:58:11: note: std::basic_ostream<char>& std::basic_ostream<char>::operator=(const std::basic_ostream<char>&) <deleted> class basic_ostream : virtual public basic_ios<_CharT, _Traits> ^ /usr/include/c++/4.8/ostream:58:11: note: no known conversion for argument 1 from ‘double’ to ‘const std::basic_ostream<char>&’
Standard output is empty