need help to making change
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 price (including any applicable tax, etc.) for whatever was purchased by the
customer.
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
amount.
• 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
this is what i have so far
import java.util.Scanner;
public class changeMaker {
/**
*
*/
public static void main(String[] args) {
Scanner keyboard= new Scanner(System.in);
int price;
int provided;
int change;
int ones= 0, fives= 0, tens= 0, twenties= 0;
int pennies= 0, nickels= 0, dimes= 0, quaters= 0;
System.out.print("Enter the purchase price:");
price = (int)Math.round(keyboard.nextDouble()*100);
System.out.print("Enter the amount given by the customer:");
provided = (int) Math.round(keyboard.nextDouble()*100);