everytime i try to compile and run the program, on the compiler it states on line
where it says ofstream outfile("c:\\Us ers\\Michael\\D esktop\\Statist ics.txt");#incl ude <iostream> that theres an error, why is that? someone help, i dont know if theres a logical error or just some other error, someone please help.....
this is the program
[code=cpp]
#include <iostream>
#include <fstream>
using namespace std;
//Program to compute statistics for how students did on exams
int main()
{
int id, students;
double rright, wrong, Tanswered, Omitted, Grade, Total;
students = 0
ofstream outfile("c:\\Us ers\\Michael\\D esktop\\Statist ics.txt");
outfile.setf(io s::fixed,ios::f loatfield);
outfile.precisi on(3);
cout << "Enter ID, right and wrong answers followed by spaces on the same line and press enter: ";
cin >> id >> rright >> wrong;
while (id != -1)
{
Tanswered = rright + wrong
Omitted = 50 - Tanswered
Percent = rright / Tanswered
Grade = rright * 2
outfile << "ID " << id << endl;
outfile << rright << " right " << wrong << " wrong" << endl;
outfile << "Total answered " << Tanswered << endl;
outfile << "Number omitted is " << Omitted << endl;
outfile << "Grade is " << Grade << endl;
if (rright > wrong)
outfile << "More right than wrong" << endl;
else
outfile << "More wrong than right" << endl;
outfile << "Correct answer pct. is " << Percent << endl;
if (Omitted > 10)
outfile << "10 or more Omitted" << endl;
else
outfile << "less than 10 omitted" << endl;
if (Omitted == 50)
outfile << "Nothing is omitted" << endl;
if (Omitted == 1)
outfile << "Almost all the questions are omitted" << endl;
Students++
cout << "Enter ID, right and wrong answers followed by spaces on the same line and press enter: ";
cin >> id >> right >> wrong;
}
outfile << "There are " << Students << " in the class" << endl;
outfile.close() ;
return 0;
}[/code]
where it says ofstream outfile("c:\\Us ers\\Michael\\D esktop\\Statist ics.txt");#incl ude <iostream> that theres an error, why is that? someone help, i dont know if theres a logical error or just some other error, someone please help.....
this is the program
[code=cpp]
#include <iostream>
#include <fstream>
using namespace std;
//Program to compute statistics for how students did on exams
int main()
{
int id, students;
double rright, wrong, Tanswered, Omitted, Grade, Total;
students = 0
ofstream outfile("c:\\Us ers\\Michael\\D esktop\\Statist ics.txt");
outfile.setf(io s::fixed,ios::f loatfield);
outfile.precisi on(3);
cout << "Enter ID, right and wrong answers followed by spaces on the same line and press enter: ";
cin >> id >> rright >> wrong;
while (id != -1)
{
Tanswered = rright + wrong
Omitted = 50 - Tanswered
Percent = rright / Tanswered
Grade = rright * 2
outfile << "ID " << id << endl;
outfile << rright << " right " << wrong << " wrong" << endl;
outfile << "Total answered " << Tanswered << endl;
outfile << "Number omitted is " << Omitted << endl;
outfile << "Grade is " << Grade << endl;
if (rright > wrong)
outfile << "More right than wrong" << endl;
else
outfile << "More wrong than right" << endl;
outfile << "Correct answer pct. is " << Percent << endl;
if (Omitted > 10)
outfile << "10 or more Omitted" << endl;
else
outfile << "less than 10 omitted" << endl;
if (Omitted == 50)
outfile << "Nothing is omitted" << endl;
if (Omitted == 1)
outfile << "Almost all the questions are omitted" << endl;
Students++
cout << "Enter ID, right and wrong answers followed by spaces on the same line and press enter: ";
cin >> id >> right >> wrong;
}
outfile << "There are " << Students << " in the class" << endl;
outfile.close() ;
return 0;
}[/code]
Comment