I have to design a Java program for a change counting game. Not C++ but Java. An
ID: 3648852 • Letter: I
Question
I have to design a Java program for a change counting game. Not C++ but Java. Any help on this would be greatHeres the problem:
"design a change-counting game that gets the user to enter the number of coins required to make exactly one dollar. the program should ask the user to enter the number of pennies, nickels, dimes, and quarters. if the total value of the coins entered is equal to one dollar, the program should congratulate the user for winning the game. otherwise, the program should display a message indicating whether the amount entered was more or less than one dollar"
Thanks for the help!
Explanation / Answer
please rate - thanks
import java.util.*;
public class main
{public static void main(String[] args)
{Scanner in=new Scanner(System.in);
int total=0,coins;
System.out.println("How many coins are needed to total 1 dollar? ");
System.out.print("pennies: ");
coins=in.nextInt();
total=total+coins;
System.out.print("nickels: ");
coins=in.nextInt();
total=total+coins*5;
System.out.print("dimes: ");
coins=in.nextInt();
total=total+coins*10;
System.out.print("quarters: ");
coins=in.nextInt();
total=total+coins*25;
if(total==100)
System.out.println("Congrats for winning");
else if(total<100)
System.out.println("You entered less than 1 dollar");
else
System.out.println("You entered more than 1 dollar");
}
}