Advertisement
Guest User

MP 1 Jar

a guest
Jan 16th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. //Cameron Roberts
  2. // Jar program
  3. import java.util.Scanner;
  4. class Jar {
  5.  
  6.     public static void main(String[] args) {
  7.         //allows input from user
  8.         Scanner input = new Scanner(System.in);
  9.        
  10.         //Ask for the number of quarters and declares the variable
  11.         double quarters;
  12.         System.out.println("How many Quarters do you have?");
  13.         quarters = input.nextDouble();
  14.        
  15.         //Ask for the number of dimes and declares the variable
  16.         double dimes;
  17.         System.out.println("How many Dimes do you have?");
  18.         dimes = input.nextDouble();
  19.        
  20.         //Ask for the number of nickels and declares the variable
  21.         double nickels;
  22.         System.out.println("How many Knickels do you have?");
  23.         nickels = input.nextDouble();
  24.        
  25.         //Ask for the number of pennies and declares the variable
  26.         double pennies;
  27.         System.out.println("How many Pennies do you have?");
  28.         pennies = input.nextDouble();
  29.        
  30.         //Declares the total amount of change to the variable total
  31.         double total;
  32.         total = (quarters * 25 + dimes * 10 + nickels * 5 + pennies *1);
  33.        
  34.         //prints results of total.
  35.         System.out.println("The jar contains " + total + " cents.");
  36.        
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement