import java.util.Scanner;
public class CoinCounter {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
double total = 0.0; // in dollars
int quarters, dimes, nickels, pennies;
System.out.println("Please enter the amount of quarters you have.");
quarters = console.nextInt();
System.out.println("Please enter the amount of dimes you have.");
dimes = console.nextInt();
System.out.println("Please enter the amount of nickels you have.");
nickels = console.nextInt();
System.out.println("Please enter the amount of Pennies you have");
pennies = console.nextInt();
total = 0.25*quarters + 0.1*dimes + 0.05*nickels + 0.01*pennies;
System.out.println("Total = $"+total);
}
}
this is supposed to be a program that takes a number input from a user in the terms of coin currency then add it up and output the amount of money they have.
i can get it to take the input from the console but i cant get it to multiply the input by the related amount a coins worth. such as someone inputs 5 for the quarters i cant multiple that 5 by .25
import java.util.Scanner;
public class CoinCounter {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.println("Please enter the amount of quarters you have.");
String value = console.nextLine();
System.out.println("Please enter the amount of dimes you have.");
String value2 = console.nextLine();
System.out.println("Please enter the amount of nickels you have.");
String value3 = console.nextLine();
System.out.println("Please enter the amount of Pennies you have");
String value4 = console.nextLine();