1. 10 5 2. (nothing is printed) 3. 5 0 4. 10 5 5. 5 10 6. 5 8 7. 0 13 8. 2 5 8 9. 10 18 8 10. -1 11. x > 3 12. y > 2 && y < 5 13. r < 0 && z > 0 14. a > 0 && b > 0 15. a < 6 || a > 10 16. x < 3 && x >= 0 17. cout << "Enter your age: "; cin >> age; if (age >= 21) cout << "You are old enough to drink\n"; else cout << "You are not old enough to drink\n"; 18. cout << "Enter your age: "; cin >> age; if (age < 17) cout << "You are not old enough to drive\n"; else if (age < 21) cout << "You are old enough to drive but too young to drink\n"; else cout << "You are old enough to drive and old enough to drink\n"; 19. cout <"Enter the area code: "; cin >> areacode; if (areacode == 732 || areacode == 973 || areacode == 908) cout << "Local call\n"; else cout << "Long distance\n"; 20. cout <"Enter the area code: "; cin >> areacode; if (areacode == 732 || areacode == 848) cout << "Local call\n"; else if (areacode == 201 || areacode == 551 || areacode == 609 || areacode == 856 || areacode == 862 || areacode == 908 || areacode == 973) cout << "In NJ\n"; else cout << "Long distance\n"; 21. cout << "Enter the temperature: "; cin >> temperature; if (temperature > 83) cout << "hot" << endl; else if (temperature >= 68) cout << "ideal" << endl; else if (temperature >= 45) cout << "cool" << endl; else cout << "cold" << endl; 22. cout << "Enter employee's job type and level: "; cin >> jobtype >> level; cout << "Enter employee's salary: "; cin >> salary; cout << "Enter the profit factor: "; cin >> profitfactor; if (jobtype == 'm') if (level >= 1 && level <= 3) bonus = salary * 0.03 * profitfactor; else bonus = salary * 0.04 * profitfactor; if (jobtype == 's' || jobtype == 'a') bonus = salary * 0.05 * profitfactor; if (jobtype == 't') if (level >= 1 && level <= 5) bonus = salary * 0.055 * profitfactor; else if (level == 6 || level == 7) bonus = salary * 0.06 * profitfactor; else bonus = salary * 0.065 * profitfactor; cout << "The bonus is $ " << bonus << endl;
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2002