-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfinance.java
More file actions
78 lines (77 loc) · 2.39 KB
/
Copy pathfinance.java
File metadata and controls
78 lines (77 loc) · 2.39 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import java.util.Scanner;
public class finance
{
public static void main (String[] args)
{
float total=0;
float weekly=0;
Scanner scan = new Scanner(System.in);
System.out.println("What is your expected annual spending for each year after retirement?");
float retirementSpending = scan.nextFloat();
System.out.println("How much do you intend on spending each year before retirement?");
float expenses = scan.nextFloat();
System.out.println("How much have you saved for retirement?");
float retirementSavings = scan.nextFloat();
System.out.println("For tax purposes, what is your yearly income?");
float income = scan.nextFloat();
if(income<9700)
{
income-=(income*0.1);
}
else if(income<39475)
{
income-=(income*0.12);
}
else if(income<84200)
{
income-=(income*0.22);
}
else if(income<160725)
{
income-=(income*0.24);
}
else if(income<204100)
{
income-=(income*0.32);
}
else if(income<510300)
{
income-=(income*0.35);
}
else
{
income-=(income*0.37);
}
System.out.println("What is your age?");
float age = scan.nextFloat();
//Everything before this line are preliminary questions to ask the user in order to calculate everything else.
//below is a loop that was initally supposed to take the spending of every day and make a weekly report, but this may be misplaced
if (retirement(retirementSpending,income,retirementSavings,age,expenses)<=0)
{
System.out.println("At this rate, you will not have enough money to retire.");
}
else
{
System.out.println("You'll have " +retirement(retirementSpending,income,retirementSavings,age,expenses)+ " years of savings at $"+retirementSpending+"per year if you retire at 67!");
}
}
//below is the calculation to find how much money the user will have at age 65
public static float retirement(float retirementSpending, float income, float retirementSavings, float age, float expenses)
{
float yearsLeft=67-age;
float moneyAt67=retirementSavings+(yearsLeft*(income-expenses));
float youHave_YearsAfterRetirement=moneyAt67/retirementSpending;
return youHave_YearsAfterRetirement;
}
public boolean goalmet(float weeklyspending, float expenses)
{
if(weeklyspending<=expenses/52)
{
return true;
}
else
{
return false;
}
}
}