Write a Java program to project your annual income over a us
Write a Java program to project your annual income over a user-defined number of years. Prompt the user to enter their graduation year, the amount of their initial income at graduation, their annual expected incomes increases as a percentage, and the number of years they would like to project. Use a while loop to control iterations. Print the year and the annual income with each year on separate lines. Please no Arrays
Solution
ProjectIncome.java
import java.text.DecimalFormat;
import java.util.Scanner;
public class ProjectIncome {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println(\"Enter graduation year: \");
int graduateYear = scan.nextInt();
System.out.println(\"Enter the amount of their initial income at graduation: \");
double amount = scan.nextDouble();
System.out.println(\"Enter annual expected incomes increases as a percentage(%): \");
double percentage = scan.nextDouble();
System.out.println(\"Enter the number of years they would like to project: \");
int years = scan.nextInt();
int year = 1;
DecimalFormat df = new DecimalFormat(\"0.00\");
while(year <= years){
double increase = (amount * percentage)/100;
amount = amount + increase;
System.out.println(\"Year: \"+(graduateYear+year)+\" Amount: \"+df.format(amount));
year++;
}
}
}
Output:
Enter graduation year:
2015
Enter the amount of their initial income at graduation:
25000
Enter annual expected incomes increases as a percentage(%):
12
Enter the number of years they would like to project:
5
Year: 2016 Amount: 28000.00
Year: 2017 Amount: 31360.00
Year: 2018 Amount: 35123.20
Year: 2019 Amount: 39337.98
Year: 2020 Amount: 44058.54
