Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Cameron Roberts
- // Jar program
- import java.util.Scanner;
- class Jar {
- public static void main(String[] args) {
- //allows input from user
- Scanner input = new Scanner(System.in);
- //Ask for the number of quarters and declares the variable
- double quarters;
- System.out.println("How many Quarters do you have?");
- quarters = input.nextDouble();
- //Ask for the number of dimes and declares the variable
- double dimes;
- System.out.println("How many Dimes do you have?");
- dimes = input.nextDouble();
- //Ask for the number of nickels and declares the variable
- double nickels;
- System.out.println("How many Knickels do you have?");
- nickels = input.nextDouble();
- //Ask for the number of pennies and declares the variable
- double pennies;
- System.out.println("How many Pennies do you have?");
- pennies = input.nextDouble();
- //Declares the total amount of change to the variable total
- double total;
- total = (quarters * 25 + dimes * 10 + nickels * 5 + pennies *1);
- //prints results of total.
- System.out.println("The jar contains " + total + " cents.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement