/* program prob2 * create a table to evaluate a formula result = f(gpa) * illustrate file I/O with separate .open() */ #include #include using namespace std; int main() { double gpa,result; ofstream outfile; //declare outfile as an ofstream object // open the output file outfile.open("c:\\bc\\CISC1110\\pgms\\chapter2\\myoutput.txt"); //comment-out for debugging //outfile.open("con"); //un-comment for debugging outfile << "\t\t\tTable of Function Values" << endl << endl; outfile << "Grade Point Average\tValue of Formula\tStatus" << endl; for (gpa = 0.00; gpa <= 4.00; gpa = gpa + 0.50) { result=(gpa*gpa*gpa+7*gpa-1)/(gpa*gpa - (gpa+5)/3); outfile << gpa << "\t\t\t" << result; if (result >= 0) outfile << "\t\t\tAdmit"; outfile << endl; } outfile << endl << "The table is finished" << endl; outfile.close(); //close the output file // system("pause"); //un-comment when using DevC++ return 0; }