//**************************************************************** // driver program to illustrate the use of the "myio" library // // Written by : Rex Forsyth // Sept 23, 2009 // Sample for CS2620 // // Use the file "intdata" to test the ints and the file "floatdata" to // test the floats //********************************************************************* #include #include #include #include using namespace std; #include "myio.h" //********************************************************************* //********************************************************************* int main() { ifstream infile; string name; int a,b; double x,y; cout << "Testing integers!! " << endl; cout << "Enter the name of the integer file -- "; getline(cin,name); openIn(infile,name); while(infile >> a >> b) { cout << "The product of " << a << " and " << b << " is " << a*b << endl; cout << endl; } infile.clear(); // clear the eof flag from this stream infile.close(); cout << "Testing doubles!! " << endl; cout << "Enter the name of the floating point file -- "; getline(cin,name); openIn(infile,name); while(infile >> x >> y) { cout << x << " + " << y << " = " << x+y << endl; cout << endl; } infile.clear(); // clear the eof flag from this stream infile.close(); do { cout << "Enter age -- "; getValid(a); cout << "Enter name -- "; getline(cin,name); cout << "Enter salary -- $"; getValid(x); 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 name (n to stop)? "; }while (tolower(getResponse('y')) != 'n'); return 0; }