In: Computer Science
Design a complete JAVA program with the following methods:-
In the main method : 3 variables are declared :- employee id, salary and status.
A method that will allow user to input employee id and salary.
A method that will assign status to “Taxable’ if employee’s salary is more than 2500RM or “Not Taxable” if salary is less and equal to 2500RM.
A method that will display the employee’s id , salary and its status.
Write the above Using Java.
Dear Student,
below i have written the complete java program as per the requirement.Please note that this program is written on lLnux environment and compiled using Javac compiler.This will also work on other IDE like Eclipse and Netbeans.
=================================================================
Program:
================================================================
// this is the scanner class
import java.util.Scanner;
//this is the main class
public class Employee_Salary
{
//global variables
public static int empid;
public static double sal;
public static String sts;
public static void main(String args[])
{
//call to methods
Input_Data();
Assign_Status();
Display();
}
//method to accept the employee data
public static void Input_Data()
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the employee id: ");
empid = in.nextInt();
System.out.print("Enter the employee salary: ");
sal = in.nextDouble();
}
//method to assign the tax status
public static void Assign_Status()
{
if(sal>2500)
{
sts = "Taxable";
}
else
{
sts = "Non-Taxable";
}
}
//dislpay the employee data
public static void Display()
{
System.out.println("Employee ID: "+empid);
System.out.println("Salary: "+sal);
System.out.println("Status: "+sts);
}
}
==================================================================
Sample Output:
==================================================================
Kindly Check and Verify Thanks...!!!