21 February 2005 - java_dev (original) (raw)
Java developers
February 21st, 2005
| | 11:23 am - partypatrol - i'm new to java and i need help. This may be a simple program to you but I need help creating a program that gives change... this is the directions:Implement a program that directs a cashier how to give change. The program has two inputs: the amount due and the amount recieved from the customer. Compute the difference, and compute the dollars, quarters, dimes, nickels, and pennies that the customer should recieve in return.First transform the difference into an integer blance, denominated in pennies. Then compute the whole dollar amount. Subtract it from the balance. Compute the number of quarters needed. Repeat for dimes and nickels. Display the remianing pennies.The class I called was Cashier... and this is what I have.public class Cashierpublic Cashier(){pennies = 1;nickels = 5;dimes = 10;quarters = 25;dollars = 100;}public void setAmountDue(double anAmountDue){amountDue = anAmountDue;}public void receive(double amountReceived){received = amountReceived}---From there I don't know what to do with the calculations because I know logically how to do it. Say the amount was 5.50andthepersongavea5.50 and the person gave a 5.50andthepersongavea10, so 10-5.50, but I don't know how to do that in the program. |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
09:05 pm - |
---|
09:24 pm - |
---|