I just need help to display my initial value of 25000 when the loop runs and print the years. I need the year 1 to be the initial value without doing the percent first. Also my print format doesnot display the $ and the headers. Any guide to the right direction will helpful.
Thank you.
import java.util.Scanner;
public class EmployeeSalary
{
public static void main(String[] args) // main method
{
final double rate = 5; // 5% raise
final double initial_balance = 25000; // initial salary
double balance = initial_balance;
System.out.print("Enter number of years: "); // employee input
Scanner in = new Scanner(System.in);
int nyears = in.nextInt();
// do the looping
for (int year = 1; year <= nyears; year++)
{
// do the math
double interest = balance * rate / 100;
balance = balance + interest;
// print the result
System.out.format("%4d %10.2f%n", year, balance);
}
}
}