Advertisement
ralphdc09

itf106.pr.wk02.number04

Jul 30th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. package pr.wk02;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class number04 {
  6.     public static void main(String[] args) {
  7.         int quarters;
  8.         int dimes;
  9.         int nickels;
  10.         int pennies;
  11.         double dollars;
  12.  
  13.         Scanner rdc = new Scanner(System.in);
  14.  
  15.         System.out.print("Enter the number of quarters:  ");
  16.         quarters = rdc.nextInt();
  17.         rdc.nextLine();
  18.  
  19.         System.out.print("Enter the number of dimes:     ");
  20.         dimes = rdc.nextInt();
  21.         rdc.nextLine();
  22.  
  23.         System.out.print("Enter the number of nickels:   ");
  24.         nickels = rdc.nextInt();
  25.         rdc.nextLine();
  26.  
  27.         System.out.print("Enter the number of pennies:   ");
  28.         pennies = rdc.nextInt();
  29.         rdc.nextLine();
  30.  
  31.         dollars = (0.25 * quarters) + (0.10 * dimes) + (0.05 * nickels) + (0.01 * pennies);
  32.  
  33.         System.out.println();
  34.         System.out.print("The total in dollars is $");
  35.         System.out.printf("%1.2f", dollars);
  36.         System.out.println();
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement