import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Coins5 { public static void main(String[] args) { try { final double PENNY_VALUE = 0.01; final double NICKEL_VALUE = 0.05; final double DIME_VALUE = 0.1; final double QUARTER_VALUE = 0.25; InputStreamReader reader = new InputStreamReader(System.in); BufferedReader console = new BufferedReader(reader); System.out.println("How many pennies do you have?"); String input = console.readLine(); int pennies = Integer.parseInt(input); System.out.println("How many nickels do you have?"); input = console.readLine(); int nickels = Integer.parseInt(input); System.out.println("How many dimes do you have?"); input = console.readLine(); int dimes = Integer.parseInt(input); System.out.println("How many quarters do you have?"); input = console.readLine(); int quarters = Integer.parseInt(input); double total = pennies * PENNY_VALUE + nickels * NICKEL_VALUE + dimes * DIME_VALUE + quarters * QUARTER_VALUE; // total value of the coins System.out.println("Total value = " + total); } catch(IOException e) { System.out.println(e); System.exit(1); } } }