For a class, I have to input a number of quarters, dimes, and nickels and output them as dollars.
If I input 4
quarters, 10
dimes, and 5
nickels, I get $225.00
, not $2.25
.
Can anyone help me, please?
public static void main(String[] args) {
System.out.print("Enter Number of Quaters: ");
Scanner quarter = new Scanner (System.in);
int quarters = quarter.nextInt();
System.out.print("Enter Number of Dimes: ");
Scanner dime = new Scanner (System.in);
int dimes = dime.nextInt();
System.out.print("Enter Number of Nickels: ");
Scanner nickel = new Scanner (System.in);
int nickels = nickel.nextInt();
DecimalFormat df = new DecimalFormat("$0.00");
System.out.print("The total is ");
System.out.println(df.format((quarters * 25) + (dimes * 10) + (nickels * 5)));
}