Hi. I'm new to java programming and I need help with this assignment.
Giving change. Implement a program that directs a cashier how to give change. The program has two inputs: the amount due and the amount received from the customer. Compute the difference, and compute the dollars, quarters, dimes, nickels, and pennies that the customer should receive in return.
So far my code look like this. But I have no clue what to do now.
import java.util.*;
public class Cashier
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("The amount due: ");
double amountDue = in.nextDouble();
System.out.print("The amount paid: ");
double amountPaid = in.nextDouble();
System.out.print("Your change is: ");
int pennies = (int)(amountPaid - amountDue)*100)
int dollars=pennies/100;
pennies=pennies%100;
int quarters = pennies/25;
pennies = pennies%25;
int dimes = pennies/10;
pennies = pennies%10;
int nickels = pennies/5;
pennies = pennies%5;
int pennies = pennies/1;
pennies = pennies%1;
System.out.println("The change due:");
System.out.println(dollars + "dollars");
System.out.println(quarters + "quarters");
System.out.println(dimes + "dimes");
System.out.println(nickels + "nickels");
System.out.println(pennies + "pennies");
}
}
Please help. Thank You.