CPE 197 Spring 2001 Test II Solution 1. cin.get(chr1); cin.get(chr1); cin.ignore(80, '\n'); cin.get(chr2); cin.get(chr2); cin.ignore(80, '\n'); cin.get(chr3); cin.get(chr3); cin.ignore(80, '\n'); 2. cout << "Please enter your age, height and weight (integers) " << " and the initials of your first and last name (characters " << "separated by a blank." << endl; cin >> age >> height >> weight >> first >> last; 3. a. !(T || F) || T = !T || T = F || T = T b. F && T && T = F && T = F c. !T || (F || !T) = F || (F || F) = F || F = F d. F || (T && (T || F)) = F || (T && T) = F || T = T e. T || T && F = T || F = T 4. #include fstream; int val1, val2, val3, val4, val5, val6, val7, val8; ifstream indat; indat.open("input.dat"); indat >> val1 >> val2 >> val3 >> val4 >> val5 >> val6 >> val7 >> val8; cout << val1 << val2 << endl << val3 << val4 << endl << val5 << val6 << endl << val7 << val8 << endl; 5. 60_ood_men, where _ is a blank 6. Level 0 Get data Compute total price Output data Level 1 Get data Read invoice number Read quantity ordered Read unit price Compute total price total = quantity * unit price Output data Print "Your invoice number is " Print invoice number Print "The quantity ordered is " Print quantity ordered Print "The unit price is " Print unit price Print "Please pay the following " Print total price 7. Madam_Now_I'm_Adam, where _ is a blank 8. double x1, y1, x2, y2; double dist; dist = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); 9. a. x is other b. x > 10\n c. x > 10\n x > 20\n d. x > 10\n x > 20\n e. x > 10\n x > 20\n f. x > 10\n x > 20\n 10. not valid as given False False True True 11. if (grade < 60) cout << "Your grade is F"; else if (grade < 70) cout << "Your grade is D"; else if (grade < 80) cout << "Your grade is C"; else if (grade < 90) cout << "Your grade is B"; else cout << "Your grade is A"; 12. Inputs: radius, choice Output: diameter, circumference, or area Algorithm: If choice is diameter Print Out 2*radius Else if choice is circumference Print Out 3.14*2*radius Else if choice is area Print Out 3.14*radius*radius 13. The ; after the } 14. char float int