Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Melinda
- //11.12.15
- //PiggyBank
- import java.util.*;
- import java.text.*;
- public class PiggyBank
- {
- public static void main(String [] args)
- {
- Scanner input = new Scanner (System.in);
- System.out.println("What is your name?");
- String name = input.nextLine();
- System.out.println("How many quarters do you have this week?");
- int quarters = input.nextInt();
- System.out.println("How many dimes do you have this week?");
- int dimes = input.nextInt();
- System.out.println("How many nickels do you have this week?");
- int nickels = input.nextInt();
- System.out.println("How many pennies do you have this week?");
- int pennies = input.nextInt();
- //calulations
- DecimalFormat df = new DecimalFormat("$###,###.00");
- double quarterValue = quarters*.25;
- double dimeValue = dimes*.10;
- double nickelValue = nickels*.05;
- double pennyValue = pennies*.01;
- System.out.println("Coin\t\tAmount");
- System.out.println("Quarters:\t\t" + quarters);
- System.out.println("Dimes:\t\t" + dimes);
- System.out.println("Nickels:\t\t" + nickels);
- System.out.println("Pennies:\t\t" + pennies);
- double totalCoins = (quarterValue + dimeValue + nickelValue + pennyValue);
- System.out.println("You have a total of $" + totalCoins);
- double weeklyAverage = totalCoins/4;
- System.out.println("You have saved a weekly average of $" + weeklyAverage);
- double yearlySavings = weeklyAverage*52;
- System.out.println(name);
- System.out.println("if you continue to save at this rate in a year you will have $" +yearlySavings);
- }
- }
Add Comment
Please, Sign In to add comment