








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
US currency is made up of notes and coins. The most common notes are $1, $5, $10, ... Print out how much money you have in quarters ($0.25 coins).
Typology: Summaries
1 / 14
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).