Chapter 4 IM Answers

Chapter 4 IM Answers - An Introduction to Programming with...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
An Introduction to Programming with C++: Fifth Edition 978-1-4188-3618-4 Chapter 4 Answers CONCEPT LESSON REVIEW QUESTIONS 1. c a memory location whose value can change while the program is running 2. d all of the above 3. a int numItems = 0; 4. c amt_Sold 5. a float 6. b initial = ‘H’; 7. c the number 0 8. c double rate = 0.0; 9. a payRate = static_cast<float>(3.56); 10. d none of the above 11. b const double RATE = 16.5; 12. d 15 13. b 5 14. b FICA (Federal Insurance Contributions Act) tax rate 15. d getline(cin, cityName); 16. d both a and b 17. c averageSales = static_cast<double>(sales1 + sales2 + sales3) / 3.0; 18. a cin.ignore(100); 19. b The int variable’s value will be temporarily converted to float . 20. c getline() function 21. d 3489.127000 22. c 3489.13 23. d all of the above
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EXERCISES – PENCIL AND PAPER 1. double price = 0.0; price = 16.23; 2. float height = 0.0; float width = 0.0; height = static_cast<float>(4.5); width = static_cast<float>(6.9); 3. int population = 0; population = 60000; 4. char letter = ‘ ’; letter = ‘A’; 5. const double TAXRATE = .15; 6. const int MAXPAY = 20; 7. const char INSURED = ‘Y’; 8. const string PROMPT = “Press any key to continue”; 9. getline(cin, company); 10. tax = taxRate * grossPay; 11. int beginStock = 0; int purchased = 0; int sold = 0; int endStock = 0; endStock = beginStock + purchased – sold; 12. const double RATE = .05; double sales = 0.0; double bonus = 0.0; bonus = sales * RATE; 13. string empName = “”; int hours = 0; double payRate = 0.0; double grossPay = 0.0; grossPay = static_cast<double>(hours) * payRate; 14. cout << fixed << setprecision(2) << totalDue << endl; 15. payRate *= 1.03; EXERCISES – COMPUTER 1. See the Cpp5\Chap04\Ch4ConE01 Solution-IM files. c. warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data d. The number 57 appears in the Command Prompt window. This is the ASCII value for the character ‘9’. e. The compiler displays an error message (error C2440: 'initializing' : cannot convert from 'const char [2]' to 'int'). 2. See the Cpp5\Chap04\Ch4ConE02 Solution-IM files. You can use the increment operator as a shortcut for adding 1 to the contents of a variable. You can use the decrement operator as a shortcut for subtracting 1 from the contents of a variable.
Background image of page 2
APPLICATION LESSON EXERCISES – COMPUTER 1. See the Cpp5\Chap04\Ch4AppE01 Solution-IM files. a. Input Processing Output sales rate (.05) Processing items: none Algorithm: 1. enter the sales 2. calculate the bonus by multiplying the sales by the rate 3. display the bonus bonus b. sales
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

Chapter 4 IM Answers - An Introduction to Programming with...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online