import java.util.Scanner; /** This program reads information about coins and prints the value of the coins. */ public class Coins { public static void main(String[] args) { // Define constants final String P_TYPE = "P"; final String N_TYPE = "N"; final String D_TYPE = "D"; final String Q_TYPE = "Q"; // Read a number and type of coin System.out.println("Enter number and type of coins: "); Scanner in = new Scanner(System.in); int numCoins = in.nextInt(); String typCoin = in.next(); // Determine and print worth of coin pile // Use output statements double value; switch(typCoin) { case "P": value = 0.01d * numCoins; break; case "N": value = 0.05d * numCoins; break; case "D": value = 0.10d * numCoins; break; case "Q": value = 0.25d * numCoins; break; default: System.out.println("Error"); return; } System.out.printf("%.2f\n", value); } }