1. Trang chủ
  2. » Kinh Doanh - Tiếp Thị

Test bank and solution manual introduction to programming WIth c (1)

14 30 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 14
Dung lượng 57,57 KB

Nội dung

Introduction to Programming with C++, Fourth Edition 2-1 Chapter Concept Lesson Questions B analyze the problem B output A input B output B IPO charts A input B entering the input items into the computer C Processing C both what is to be calculated and how to calculate it 10 C entering the input items, then processing the input items, and then displaying, printing, or storing the output items 11 D pseudocode 12 A Flowcharts 13 C process 14 A input/output 15 D 16 C 17 B 18 C desk-check the algorithm 19 D all of the above Concept Lesson Exercises Input original number Processing Processing items: none Output squared value Algorithm: enter original number calculate the squared value by multiplying the original number by itself display the squared value original number squared value 16 36 Introduction to Programming with C++, Fourth Edition Input state1 sales state2 sales commission rate state1 sales 1000 3000 Input sales commission rate Processing Processing items: none Output commission Algorithm: enter state1 sales, state2 sales, and commission rate calculate the total commission by adding the state1 sales to the state2 sales, and then multiplying the result by the commission rate display the total commission state2 sales 2000 2500 commission rate 05 06 Processing Processing items: none start enter the sales and commission rate calculate the commission by multiplying the sales by the commission rate display the commission stop commission rate 06 commission 150 330 Output commission Algorithm: sales 2000 5000 2-2 commission 200 300 Introduction to Programming with C++, Fourth Edition 2-3 Input region1 sales region2 sales region3 sales region1 increase region2 increase region3 increase Processing Processing items: none Algorithm: enter the region1 sales, region2 sales, region3 sales, region1 increase, region2 increase, and region3 increase calculate the region1 projected sales by multiplying the region1 sales by the region1 increase calculate the region2 projected sales by multiplying the region2 sales by the region2 increase calculate the region3 projected sales by multiplying the region3 sales by the region3 increase display the region1 projected sales, region2 projected sales, and region3 projected sales Output region1 projected sales region2 projected sales region3 projected sales region1 region2 region3 region1 region2 region3 region1 sales sales sales increase increase increase projected sales 10000 3000 6000 09 11000 5000 2000 1000 02 03 02 5100 Input original number Processing Processing items: none region3 projected sales 6600 1020 Output squared value Algorithm: enter original number if the original number is less than or equal to zero display an error message otherwise calculate the squared value by multiplying the original number by itself display the squared value original number 10 -3 region2 projected sales 3270 2060 squared value 100 Introduction to Programming with C++, Fourth Edition Results of desk-checking the incorrect algorithm beginning inventory amount sold amount returned 50 10 Changes made to the original algorithm are shaded in the IPO chart Input Processing beginning inventory Processing items: none amount sold amount returned Algorithm: enter the beginning inventory, amount sold, and amount returned calculate the ending inventory by subtracting the amount sold from the beginning inventory, then adding the amount returned to the result display the ending inventory Results of desk-checking the correct algorithm beginning inventory amount sold amount returned 50 10 2-4 ending inventory 58 Output ending inventory ending inventory 42 Changes made to the original algorithm are shaded in the IPO chart Input Processing hours worked Processing items: none rate of pay Algorithm: enter the hours worked and rate of pay calculate the gross pay by multiplying the hours worked by the rate of pay display the gross pay Output gross pay Introduction to Programming with C++, Fourth Edition Application Lesson Exercises Input Processing room length Processing items: room width room perimeter ceiling height wall area single roll coverage Algorithm: start enter the room length, room width, ceiling height, and single roll coverage room perimeter = add together the room length and room width, and then multiply the sum by wall area = room perimeter multiplied by the ceiling height number of single rolls = divide the wall area by the single roll coverage display the number of single rolls stop 2-5 Output number of single rolls Introduction to Programming with C++, Fourth Edition 2-6 Input beginning balance monthly deposits monthly withdrawals Processing Processing items: none beginning balance 2000 500 monthly deposits 775 100 Input first number second number third number first number 25 10 Output ending balance Algorithm: enter the beginning balance, monthly deposits, and monthly withdrawals calculate the ending balance by adding the monthly deposits to the beginning balance, and then subtracting the monthly withdrawals from the result display the ending balance monthly withdrawals ending balance 1200 1575 610 -10 Processing Processing items: none Output average Algorithm: enter the first number, second number, and third number calculate the average by adding together the first number, second number, and third number, and then dividing the sum by 3 display the average second number 76 15 third number 33 20 average 44.6666 15 Introduction to Programming with C++, Fourth Edition Input original price discount rate 2-7 Processing Processing items: none Output sales discount new price Algorithm: enter original price and discount rate calculate the sales discount by multiplying the original price by the discount rate calculate the new price by subtracting the sales discount from the original price display the sales discount and the new price original price 100 50 discount rate 25 Input number of envelopes number of pages charge per envelope charge per page sales discount 25 new price 75 45 Processing Processing items: total envelope charge total page charge Output total due Algorithm: enter the number of envelopes, number of pages, charge per envelope, and charge per page calculate the total envelope charge by multiplying the number of envelopes by the charge per envelope calculate the total page charge by multiplying the number of pages by the charge per page calculate the total due by adding the total envelope charge to the total page charge display the total due number of envelopes number of pages charge per envelope 100 10 100 15 10 20 charge total per page envelope charge 25 10 30 total page charge total due 25 4.50 35 6.50 Introduction to Programming with C++, Fourth Edition Input first seminar attendees second seminar attendees seminar price first seminar attendees 10 30 Input hours worked hourly pay rate FWT rate FICA rate state rate hours worked 20 30 hourly pay rate 10 2-8 Processing Processing items: none Algorithm: enter the first seminar attendees, second seminar attendees, and seminar price calculate the total attendees by adding together the first seminar attendees and the second seminar attendees calculate the cost by multiplying the total attendees by the seminar price display the total attendees and the cost second seminar attendees seminar price 10 200 10 100 total attendees 20 40 Processing Processing items: total taxes Algorithm: enter the hours worked, hourly pay rate, FWT rate, FICA rate, and state rate calculate the gross pay by multiplying the hours worked by the hourly pay rate calculate the FWT by multiplying the gross pay by the FWT rate calculate the FICA by multiplying the gross pay by the FICA rate calculate the state tax by multiplying the gross pay by the state rate calculate the total taxes by adding together the FWT, FICA, and state tax calculate the net pay by subtracting the total taxes from the gross pay display the gross pay, FWT, FICA, state tax, and net pay FWT rate 2 FICA rate 08 08 state rate 02 04 total taxes 36 96 gross pay 120 300 Output total attendees cost FWT FICA 24 60 9.60 24 cost 4000 4000 Output gross pay FWT FICA state tax net pay state tax 2.40 12 net pay 84 204 Introduction to Programming with C++, Fourth Edition Input side1 side2 side3 side4 Processing Processing items: none Output perimeter Algorithm: enter side1, side2, side3, and side4 calculate the perimeter by adding together side1, side2, side3, and side4 display the perimeter The desk-check data may vary side1 side2 10 20 10 Input diameter price per foot 2-9 side3 15 Processing Processing items: none Algorithm: start enter the diameter and price per foot circumference = diameter multiplied by pi (3.14) total price = circumference multiplied by price per foot display the circumference and price per foot stop side4 20 perimeter 29 65 Output circumference total price Introduction to Programming with C++, Fourth Edition The desk-check data may vary diameter price per foot 35 10 Input length in feet width in feet price per square foot of tile 11 Input length in feet width in feet height in feet total price 219.80 65.94 Processing Processing items: none Output area total price Algorithm: enter the length in feet, width in feet, and price per square foot of tile calculate the area by multiplying the length in feet by the width in feet calculate the total price by multiplying the area by the price per square foot of tile display the area and total price The desk-check data may vary length in feet width in feet 10 20 circumference 109.90 21.98 2-10 10 price per square foot of tile area total price 60 200 300 600 Processing Processing items: none Output volume Algorithm: enter the length in feet, width in feet, and height in feet calculate the volume by multiplying the length in feet by the width in feet, and then multiplying the result by the height in feet display the volume The desk-check data may vary length in feet width in feet 100 30 height in feet volume 9000 24 Introduction to Programming with C++, Fourth Edition 12 Input current pay1 current pay2 current pay3 raise rate current pay1 7.55 8.00 2-11 Processing Processing items: none Algorithm: enter the current pay1, current pay2, current pay3, and raise rate calculate the new pay1 by multiplying the current pay1 by the raise rate, and then adding the result to the current pay1 calculate the new pay2 by multiplying the current pay2 by the raise rate, and then adding the result to the current pay2 calculate the new pay3 by multiplying the current pay3 by the raise rate, and then adding the result to the current pay3 display the new pay1, new pay2, and new pay3 current pay2 10.00 6.50 current pay3 10.30 7.25 Output new pay1 new pay2 new pay3 raise rate new pay1 new pay2 new pay3 02 02 7.70 8.16 10.20 6.63 10.51 7.40 13 Input Processing semester hours Processing items: none tuition per semester hour room and board fee Algorithm: start enter the semester hours, tuition per semester hour, and room and board fee total cost = multiply the semester hours by the tuition per semester hour, and then add the room and board fee to the result display the total cost stop Output total cost Introduction to Programming with C++, Fourth Edition semester hours 20 14 tuition per semester hour 100 100 room and board fee 3000 3000 14 Input hours worked hourly pay rate Processing Processing items: overtime pay 2-12 total cost 5000 4400 Output gross pay Algorithm: enter the hours worked and hourly pay rate if the hours worked is greater than 40 calculate the overtime pay as follows: first subtract 40 from the hours worked, then multiply the result by the hourly pay rate divided by calculate the gross pay by multiplying the hours worked by the hourly pay rate, and then adding the overtime pay to the result otherwise calculate the gross pay by multiplying the hours worked by the hourly pay rate display the gross pay hours worked 20 43 hourly pay rate 10 overtime pay 45 15 Changes to the original algorithm are shaded in the figure gross pay 120 445 Introduction to Programming with C++, Fourth Edition Input number Processing Processing items: none Algorithm: enter the number calculate the cube of the number by multiplying the number by itself three times display the cube of the number number cube of the number 64 2-13 Output cube of the number Introduction to Programming with C++, Fourth Edition 16 Input original price discount rate Processing Processing items: none Output discount sale price Algorithm: enter the original price and the discount rate calculate the discount by multiplying the original price by the discount rate calculate the sale price by subtracting the discount from the original price display the discount and the sale price original price 100 2-14 discount rate discount sale price 25 25 75 ... the diameter and price per foot circumference = diameter multiplied by pi (3.14) total price = circumference multiplied by price per foot display the circumference and price per foot stop side4... Output circumference total price Introduction to Programming with C+ +, Fourth Edition The desk-check data may vary diameter price per foot 35 10 Input length in feet width in feet price per square... the charge per envelope calculate the total page charge by multiplying the number of pages by the charge per page calculate the total due by adding the total envelope charge to the total page charge

Ngày đăng: 18/08/2020, 10:34