Advertisement
Guest User

Untitled

a guest
May 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Jar_Problem {
  4.     public static void main(String[] args) {
  5.         int value1 = 0, value2 = 0, value3 = 0, value4 = 0, tot = 0;
  6.         double total = 0.0, cents = 0.0;
  7.        
  8.         Scanner scan = new Scanner(System.in);
  9.        
  10.         System.out.print("Enter in the number of Quarters in the Jar: ");
  11.         value1 = scan.nextInt();
  12.         System.out.print("Enter in the number of Dimes in the Jar: ");
  13.         value2 = scan.nextInt();
  14.         System.out.print("Enter in the number of Nickles in the Jar: ");
  15.         value3 = scan.nextInt();
  16.         System.out.print("Enter in the number of Pennies in the Jar: ");
  17.         value4 = scan.nextInt();
  18.        
  19.         total = value1 *.25 + value2 * .1 + value3 * .05 + value4 * .01;
  20.         cents = total % 1;
  21.         tot = (int) total;
  22.  
  23.         System.out.println("\nThe jar contains " + tot + " dollar(s) and " + cents + " cents.");
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement