# 数组利率：具有程序员的障碍

• 1-5年级：6％
• 6-10年级：2％
• 11-15年：15％
• 16-18年：0％
• 19-20年：30％
• 26-30年：3％

``````    import java.util.Scanner;

public class Project3Revised {
public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int salary;
double savingsRate;
double[] interestRate;
double employmentYears;
double retirementSavings;

System.out.println("Enter input salary savings_rate lastname firstname");

salary = scnr.nextInt();
savingsRate = scnr.nextDouble();
interestRate = scnr.nextDouble();
employmentYears = 30
String l = scnr.next(); // Last Name
String f = scnr.next(); // First Name
retirementSavings = employmentYears * savingsRate * salary * (1 + interestRate);

if (salary < 0) {
System.out.println("Salary is negative");
}
else if (salary > 1000000) {
System.out.println("Error: Salary " + salary + "exceeds maximum 1000000.0");
}
else {
System.out.println("Salary: " + salary);
}

if (savingsRate < 0) {
System.out.println("Savings rate is negative");
}
else if (savingsRate > 0.5) {
System.out.println("Error: Savings rate " + savingsRate + "exceeds maximum 0.5");
}
else {
System.out.println("Savings Rate:" + savingsRate);
}

if (interestRate < 0) {
System.out.println("Interest Rate is negative");
}
else if (interestRate > 0.25) {
System.out.println("Error: Interest Rate " + interestRate + "exceeds maximum 0.25");
}
else {
System.out.println("Interest Rate: " + interestRate);
}

if (employmentYears < 0) {
System.out.println("Years employed is negative!");
}
else if (employmentYears > 50) {
System.out.println("Error: Years employed " + employmentYears + "exceeds maximum 50");
}
else {
System.out.println("Years of Employment: " + employmentYears);
}

if (l.length() == 0 || l.length() == 1) {
System.out.println("Error: Name too short");
}
else if (l.equals(f)) {
System.out.println("Error: Last Name and First Name are the same");
}
else {
System.out.println("Last Name: " + l);
}

if (f.length() == 0 || f.length() == 1) {
System.out.println("Error: Name too short");
}
else if (f.equals(l)) {
System.out.println("Error: Last Name and First Name are the same");
}
else {
System.out.println("First Name: " + f);
}

System.out.println("Retirement Savings: " + retirementSavings);

System.out.println(" ");
System.out.println(" ");

int year;
double interestEarned;
double balance;
double multiplicator; // Interest earned plus an increment

year = 0;
interestEarned = salary * interestRate;
balance = salary * savingsRate + interestEarned;
multiplicator = 1 + interestRate;

/* while (year <= employmentYears) {
++year;
System.out.println("Year: " + year + " Interest Earned: " + interestEarned + " Balance: " + balance);
interestEarned = interestEarned * multiplicator;
balance = balance * multiplicator;
*/

for (int year = 0; )
}

}
}
``````