CS139 Algorithm Development

Software Requirements Specification

Programming Assignment 1

Change Maker

Due Friday, September 24 by 5:00pm 


Introduction

Purpose: This program is designed to calculate and display the number of coins required to make change for an amount read in from the keyboard. 

Objectives - At the conclusion of this exercise the student will demonstrate that they can:

Deadlines

Prerequisites

You have covered the material in Chapter 2 of Gaddis.  

Background

When making change, there is a process that cashiers use involving counting back from the highest coin available through the lowest. So if I needed to make $.87 cents in change, I would first determine how many quarters I needed. 3 will give $.75 leaving 12 cents to go. I would then count out 1 dime leaving 2 cents. Since nickels are too large, I would have 0 nickels and 2 pennies. In this program, you will build a change maker which will display for any given amount the number of dollar, quarter, dime, nickel, and penny amounts required to make that amount of change.

Example

$1.42 would be 1 dollar, 1 quarter, 1 dime, 1 nickel, and 2 penney coins.

Program Behavior

Your application must be named ChangeMaker.  

Your application must do these things:

  1. Your program will prompt for and read one input values.  It is:
    1. The amount to make change for as a double.
  2. Your application must calculate the number of each coin required to make the change.
  3. Your application must display the change in the format specified below. 

Output

  1. Output the heading, "Welcome to the Change Maker" followed by the newline character.
  2. Output a blank line.
  3. Prompt for the input values. Output the newline character after reading the each input value and before the next prompt. Note: your input will be on the same line as the prompt.
    1. Your first input prompt must be the String, "Enter the total amount of change: ".
  4. After reading the input values, output a blank line then the name of the heading, "Amount of change for $A.AA is:". Substitute the amount entered for the A.AA. 
  5. On the next line print out a tab character, then  " Dollars: DDD" Substitute the number of dollar coins for the DDD.
  6. On the next line print out a tab character, then  "Quarters: QQQ" Substitute the number of quarter coins for the QQQ.
  7. On the next line print out a tab character, then  " Dimes: DDD" Substitute the number of dime coins for the DDD.
  8. On the next line print out a tab character, then  " Nickels: NNN" Substitute the number of nickel coins for the NNN.
  9. On the next line print out a tab character, then  " Pennies: PPP" Substitute the number of penney coins for the PPP.

Sample output

Welcome to the Change Maker
Enter the total amount of change:  

Amount of change for $1.42 is:
Dollars: 1
Quarters: 1
Dimes: 1
Nickels: 1
Pennies: 2

Error handling

You will not need to perform any error handling.  Assume that the values being entered is a double.

Additional Program Requirements

  1. You must use variables for the values of the input.
  2. You must use constants for the value of each of the coins.
  3. In the documentation for the main method, you must supply three different examples of the calculation, showing the change value and coin quantities.  You may use your group's examples from class. This is worth 10 points.
  4. Your program must conform to standard Java programming standards and the additional standards for this class. See the Style Guide for your class.

Honor Code

This work must conform to the JMU Honor Code and the specific requirements of this class. NO help may be provided by any student to another student. Authorized help is limited to your textbook, the TAs for any CS139 or CS239 section, and the professor for your section. See collaboration policy.

Grading

        For submissions after:

HINTS