Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a JAVA program that reads salary of 10 employee using a loop. Write a meth

ID: 3556559 • Letter: W

Question

Write a JAVA program that reads salary of 10 employee using a loop. Write a method

public static int SalaryCode(double Salary)

That return the salary code. the main function should ask the user input for employment salary and pass it when calling the method. the method should check the salary and return the salary code as following.

If the salary is more than 10000 the salary code is 3.

If the salary is between 50000 and 100000, the salary code is 2.

If salary is less than 50000, thje salary code is 1.

Explanation / Answer

import java.util.Scanner;
public class Salary {

   public static int SalaryCode(double Salary) {
      if(Salary > 100000)
         return 3;
      if(Salary >= 50000 && Salary <= 100000)
         return 2;
      if(Salary < 50000)
         return 1;
      return 0;
   }
   public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      double[] salaries = new double[10];
      for(int i=0; i<10; ++i) {
         System.out.print("Enter salary for person " + (i+1) + " : ");
         salaries[i] = scan.nextDouble();
         System.out.println("Salary Code for person : " + SalaryCode(salaries[i]));
      }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote