Design a class Employee with the following descriptions:
Data members:
Name : to store the name of the employee
Code : to store the employee code Address : to store the address of the employee
Sal: to store the monthly salary
Incr: to store the incremented salary Member functions:
void input(): to input the details of the employee from the user.
void increase (): to calculate incremental salary.
(10% of salary if salary is more than 20000 otherwise 5% salary)
void print(): to print all the details.
Answers
Answered by
2
As You haven't mentioned me the programming language.
I will assume it as Java
The Code Is As Follows:
import java.util.*;
import java.util.*;public class Employee
import java.util.*;public class Employee{
public static void main ()
{
Scanner sc = new Scanner (System.in);
String n;
char c;
double s; //s is Salary
double i; //increment
System.out.println ("Enter Employee Name:");
n = sc.next();
System.out.println ("Enter Employee code:");
c = sc.next().charAt(0);
System.out.println ("Enter Monthly Salary:");
s = sc.nextDouble();
if (s>20000.0)
{
i = s+(10/100*s);
}
else
{
i = s+(5/100*s);
}
System.out.println ("Employee Name:"+n);
System.out.println ("Employee Code:"+c);
System.out.println ("Salary:"+s);
System.out.println ("Incremented Salary:"+i);
}
}
Similar questions