I got a homework, its due by monday. I have read textbook a lot but i still dont know what to do next steps.
Here is problem.
The program should prompt the user for and accept two inputs:
1. The total price (including any applicable tax, etc.) for whatever was purchased by the
2. The amount of money provided to the cashier by the customer

Given this information, the program should provide output as follows

• Display appropriate messages if the customer provided to little money or the exact
• Otherwise, display the number of bills and coins that should be given to the customer
as change.
• Change should be provided using the largest bill and coin denominations as possible.
The available bill denominations are $20, $10, $5 and $1; the available coin
denominations are 25¢, 10¢, 5¢, 1¢ (there are no half-dollar coins). For example, if
the change amount is $26.56, the customer should be given one $20 bill, one $5 bill,
one $1 bill, two quarters, one nickel, and one penny.
• Denominations that are not used should not be displayed. For example, in Sample
Run 2 below, the dime coin is not included in the output.

Important: You should store all of your amounts as cents using Java’s int type, not double.
In order to allow users of your program to enter amounts normally, you should convert entered
dollar amounts to cents by multiplying by 100 and “casting” from double to int, e.g.:

int price = (int) Math.round(keyboard.nextDouble()*100);

Sample Run 1

Enter the purchase price: 13.44
Enter amount provided by customer: 15.00
The customer should be given change as follows:
1 $1 bill(s)
2 quarter coin(s)
1 nickel coin(s)
1 penny coin(s)

Sample Run 2

Enter the purchase price: 13.44
Enter amount provided by customer: 13.44
No change is necessary!!

Sample Run 3

Enter the purchase price: 26.14
Enter amount provided by customer: 100.00
The customer should be given change as follows:
3 $20 bill(s)
1 $10 bill(s)
3 $1 bill(s)
3 quarter coin(s)
1 dime coin(s)
1 penny coin(s)

please help me about this topic.
Thank you!!

5 Years
Discussion Span
Last Post by CoolPrizes

i started write code like this. I don know what to do after ...

public static void main(String[] args) {
    Scanner Keyboard=new Scanner(System.in);
    System.out.println("Enter the purchase price");
    int dollar1,dollar2;
    dollar1 = (int)Math.round(Keyboard.nextDouble()*100);

    System.out.println("Enter amount provide by customer");
    dollar2 = (int)Math.round(Keyboard.nextDouble()*100);
    int totalChange = dollar2 - dollar;


Edited by Nick Evan: Fixed formatting


Nvm. I thought you went to the same highschool as me. This is also due on monday for me.. o-O

Edited by CoolPrizes: Nevermind. You're located in Maryland. I'm located in California! LOL

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.