-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit2_Main.java
32 lines (25 loc) · 1.13 KB
/
unit2_Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* budget.java
* Sean Cochran
* This program will calculate yearly savings based on input from the user
*/
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner stdln = new Scanner(System.in);
double annualIncome; // Total income earned in one year.
double monthlyPercentage; // The percentage of monthly income to send to savings.
double yearlySavings; // Total amount that will be saved in one year.
double monthlySavings; // Total amount that will be saved in one year.
System.out.print("How much money do you take home in a year?");
annualIncome = stdln.nextDouble();
System.out.print("Enter the percentage of monthly income do you want to save in decimal (example: .10 for 10%)");
monthlyPercentage = stdln.nextDouble();
monthlySavings = (annualIncome / 12) * monthlyPercentage;
System.out.print("You will save $" + Double.toString(monthlySavings) + " per month.");
yearlySavings = monthlySavings * 12;
System.out.print(" This will total $" + Double.toString(yearlySavings) + " over the course of one year. Great job!");
}
}