P1 Change Machine Solution

$30.00

Description

 

Write a program that will calculate what coins should be returned when giving change at a store. You are to write the program that simulates the “thinking” of the change machine.

Your program needs to prompt the user for an integer, which represents the total value that your machine should give in change. This inputted value will always be in the range of 0-99 cents, since the dollar amount will always be payed out in cash.

As a rule, your program should give as many larger value coins as it can, before giving coins of lesser value.

For example, if the change to be given was 86 cents, your program would say that it should return 3 quarters, 1 dime and 1 penny. Your change machine can only give quarters, dimes, nickels and pennies.

Here is an example of what your output could look like:

The Happy Change Machine

Enter the amount of change to be given: 87

Your change is

  1. quarters

  1. dimes

  1. nickels

  1. pennies

Your program and all further programs should have program description header that goes at the top of the file which gives information about the programmer and program.

////

  • Name: Bob Programmer

  • Section: A, B, or S

  • Program Name: Hello World

  • Description: A brief description of the program. What does the

  • program do (not how it does it: for example, it uses loops)? Does

  • the program get input? What kind? What information is output

  • from the program and to where (screen or file)

////

#include <…>

Run your program three times with the input values of 8, 42 and 99. For each time that you run your program copy your program output to the bottom of your code. You can place these three program outputs in a comment section (/* before the beginning, and */ at the end of the output) so that your program could still run with them included in the cpp file. To copy from the Command Window, select the icon in the upper left corner, then select Edit/Select All. Then press Enter key on your keyboard to copy the text. Next paste it below your program and then make it to a comment by placing the /* output over many lines */.

Turn in a print out of you cpp file with the output, and hand this in at the beginning of class on the designated day.

Grading: I will be looking at the following things:

  • Do you have a program description as shown in the above example?

  • Did you include the output from the 3 test runs, and get the correct output?

  • Is your output easy to read?

  • Did you choose good variable names?

  • Did you indent the code properly?

  • Did you avoid any line-wrap (lines that are too long and so the wrap around when printed)?


error: Content is protected !!