/* program prob2 * create a table to evaluate a formula result = f(gpa) * illustrate redirection of cout to a file */ #include #include using namespace std; int main() { double gpa,result; //un-comment to redirect cout to a file //ofstream cout("c:\\bc\\CISC1110\\pgms\\chapter2\\myoutput.txt"); cout << "\t\t\tTable of Function Values" << endl << endl; cout << "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); cout << gpa << "\t\t\t" << result; if (result >= 0) cout << "\t\t\tAdmit"; cout << endl; } cout << endl << "The table is finished" << endl; //un-comment when redirecting cout to a file // cout.close(); //close output file // system("pause"); //un-comment when using DevC++ return 0; }