//**************************************************************** // driver program to illustrate the use of library // // Written by : Rex Forsyth // Nov 26 2001 // An example for CS1620 B // // Use the file "intdata" to test the ints and the file "floatdata" to // test the floats //********************************************************************* #include #include #include #include #include "myio.h" using namespace std; //********************************************************************* //********************************************************************* int main() { ifstream infile; string filename; string name; int a,b; double x,y; cout << "Enter name of input file of integers -- "; cin >> filename; openIn(infile,filename); while(true) { infile >> a >> b; if (infile.eof()) break; cout << "The product of " << a << " and " << b << " is " << a*b << endl; } infile.clear(); // clear the eof flag from this stream infile.close(); cout << "Enter name of input file of reals -- "; cin >> filename; openIn(infile,filename); while(true) { infile >> x >> y; if (infile.eof()) break; cout << x << " + " << y << " = " << x+y << endl; cout << endl; } infile.clear(); // clear the eof flag from this stream infile.close(); do { cout << "Enter name -- "; cin >> name; clrStream(); cout << "Enter age -- "; getValid(a); clrStream(); cout << "Enter salary -- $"; getValid(x); clrStream(); cout << "Hello " << name << ". You are a"; if (a < 12) cout << " child, "; else if (a < 18) cout << " teenager, "; else if (a < 65) cout << "n adult, "; else cout << " senior citizen, "; cout << "who is "; if (x<20000.00) cout << "poor."; else if (x >100000.00) cout << "rich."; else cout << "middle class."; cout << endl << endl; cout << "Another person (n to stop)? "; }while (tolower(getResponse('y')) != 'n'); return 0; }