


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Java Assignment: Least Change Assignment Competencies: Creating a design tool Structuring a program Random Number Generation Basic decision statement Basic loop Variables Specifications: You are to design, write, test and submit a solution for the following: Write a short program that will generate a random number between 0 and 99. The random number will represent the amount of coin (change) from a money transaction. Based on the random number, you are to determine the least possible coins to make change. For example: Total change = 82 Half Dollar …….. 1 Quarter ……..…. 1 Nickel ….……… 1 Pennies………. 2 For example: Total change = 22 Dimes ….…….. 2 Pennies………. 2 For example: Total change = 76 Half Dollar …….. 1
Quarter ……..…. 1 Penny………….. 1 Other rules: If there are no coin type then it does not appear. If there is one of a coin type then the word is singular If there is more than one of a coin type then the word is plural You are to have your program produce 5 different random change transactions. Note: comments within your source code is not a design tool. You are to attach your *.java source code. Forbidden NEVER use global variables or NEVER use goto.
System.out.println(nickels + " Nickel" + ((nickels > 1)? "s" : "")); } if (pennies > 0) { System.out.println(pennies + " Penny" + ((pennies > 1)? "s" : "")); } System.out.println(); } } }