








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!









Next write a class called Notes which has: ● A private integer called quantityOnHand ● A private integer called denomination ● A constructor which takes one integer called denomination and sets the object attributes. ● A method called getTotalValue() which returns a int representing the total value of this note (denomination * quantityOnHand) ● A method called increaseQuantity which takes in a quantity (int) and increases the quantityOnHand by that amount. ● A method called decreaseQuantity which takes in a quantity (int) and decreases the quantityOnHand by that amount. Note, you can never have less than 0 of any note. If you are asked to decreaseQuantity below 0, just set it to 0. ● A method called getQuantityOnHand which takes in no parameters, and returns the value of the quantityOnHand attribute (an int). ● A method called printPretty which takes in a float called amount, and returns a string. The body of the method will be: Java:
● An override of toString (java) or ToString (C#) which returns a string like “$32. in $1.00 notes”. The first value should be the total value of the note, the second value should be the denomination of this note. Finally, write a main method. Start it with the following code: Notes twenties=new Notes(20); Notes tens=new Notes(10); Notes fives=new Notes(5); Notes ones=new Notes(1); Coins quarters=new Coins(0.25f,0.2f); Coins dimes=new Coins(0.10f,0.08f); Coins nickels=new Coins(0.05f,0.176f); Coins pennies=new Coins(0.01f,0.088f); dimes.increaseQuantity(41); nickels.increaseQuantity(17); pennies.increaseQuantity(132); ones.increaseQuantity(33); fives.increaseQuantity(12); tens.increaseQuantity(2); twenties.increaseQuantity(5);
$100.00 in $20.00 notes. $20.00 in $10.00 notes. $60.00 in $5.00 notes. $33.00 in $1.00 notes. $0.00 in $0.25 coins. $4.10 in $0.10 coins. $0.85 in $0.05 coins. $1.32 in $0.01 coins. Total Money is $219.27 total weight is 17.888oz How much do you need?
Give them a $20 note Give them a $20 note Give them a $1 note Give them a $1 note Give them a dime Give them a dime Give them a dime Give them a dime
Give them a nickel Give them a penny Give them a penny I have $176.80 left, it's total weight is 17.216oz
$100.00 in $20.00 notes. $20.00 in $10.00 notes. $60.00 in $5.00 notes. $33.00 in $1.00 notes. $0.00 in $0.25 coins. $4.10 in $0.10 coins. $0.85 in $0.05 coins. $1.32 in $0.01 coins. Total Money is $219.27 total weight is 17.888oz How much do you need?
Give them a $10 note Give them a $5 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a dime Give them a dime Give them a nickel Give them a penny Give them a penny I have $200.00 left, it's total weight is 17.376oz
$100.00 in $20.00 notes. $20.00 in $10.00 notes. $60.00 in $5.00 notes. $33.00 in $1.00 notes. $0.00 in $0.25 coins. $4.10 in $0.10 coins.
Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a $1 note Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime
Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a dime Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a nickel Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny
Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny
Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny Give them a penny I don't have enough money. I still owe you $0. I have $0.00 left, it's total weight is 0oz
○ Correctly calculates total value(1 point) ● Method increaseQuantity (3 points total) ○ Takes one parameter of type int (1 point) ○ Correctly increases the quantityOnHand by the parameter (2 points) ● Method decreaseQuantity (3 points total) ○ Takes one parameter of type int (1 point) ○ Correctly decreases the quantityOnHand by the parameter (2 points) ● Method getQuantityOnHand (3 points total) ○ Takes in no parameter (1 point) ○ Returns an integer (1 point) ○ Correctly returns the quantityOnHand. ● Override of toString/ToString (5 points total) ○ Correct override method header (2 points) ○ Correctly returns the appropriate string (2 points) ○ Uses prettyPrint() correctly (1 point) Notes Class (23 points total): ● 2 attributes (4 points total) ○ 1 point for attribute defined private, one for correct type used. ● Constructor (2 points total) ○ Takes in 1 parameters of correct type (1 points) ○ Correctly sets object variables (1 points) ● Method getTotalValue (3 points total) ○ Takes no parameters (1 point) ○ Returns an int (1 point) ○ Correctly calculates total value(1 point) ● Method increaseQuantity (3 points total) ○ Takes one parameter of type int (1 point) ○ Correctly increases the quantityOnHand by the parameter (2 points) ● Method decreaseQuantity (3 points total) ○ Takes one parameter of type int (1 point) ○ Correctly decreases the quantityOnHand by the parameter (2 points) ● Method getQuantityOnHand (3 points total) ○ Takes in no parameter (1 point) ○ Returns an integer (1 point) ○ Correctly returns the quantityOnHand. ● Override of toString/ToString (5 points total) ○ Correct override method header (2 points) ○ Correctly returns the appropriate string (2 points) ○ Uses prettyPrint() correctly (1 point)
Driver class/program (37 points total): ● Correctly copied/pasted object instantiation & increaseQuantity code (2 points total) ● Correctly uses toString/ToString in each object to print out value of each note/coin (There should be 8 lines - 1 point each) ● Correctly calculates the total value of money they have (5 points) ● Correctly calculates the total weight of the coins (4 points) ● Correctly prints out the total value of money as well as total weight of coins ( point) ● Correctly calculates how many $20’s to give. Prints out the right number of “Give them a $20 note” lines, and correctly keeps track of how many $20’s are left. ( points) ● Correctly calculates how many $10’s to give…(2 points) ● Correctly calculates how many $5’s to give…(2 points) ● Correctly calculates how many $1’s to give…(2 points) ● Correctly calculates how many quarters to give…(2 points) ● Correctly calculates how many dimes to give…(2 points) ● Correctly calculates how many nickels to give…(2 points) ● Correctly calculates how many pennies to give…(2 points) ● Correctly calculates the final amount of money left, and it’s weight and prints it ( point).