Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Jar_Problem {
- public static void main(String[] args) {
- int value1 = 0, value2 = 0, value3 = 0, value4 = 0, tot = 0;
- double total = 0.0, cents = 0.0;
- Scanner scan = new Scanner(System.in);
- System.out.print("Enter in the number of Quarters in the Jar: ");
- value1 = scan.nextInt();
- System.out.print("Enter in the number of Dimes in the Jar: ");
- value2 = scan.nextInt();
- System.out.print("Enter in the number of Nickles in the Jar: ");
- value3 = scan.nextInt();
- System.out.print("Enter in the number of Pennies in the Jar: ");
- value4 = scan.nextInt();
- total = value1 *.25 + value2 * .1 + value3 * .05 + value4 * .01;
- cents = total % 1;
- tot = (int) total;
- System.out.println("\nThe jar contains " + tot + " dollar(s) and " + cents + " cents.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement