Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Saturday, 5 November 2011

Write a class name employee. This class should hold the employee's details such as employee id,name,gender,salary and position. Write a member function to input all these details and displaying the information on the screen. Supply another member function to calculate the net salary for an employee (by Syuhadah razak)


import java.util.*;
class employee
{
public static void main (String args[])
{
employeeinfo ob = new employeeinfo();
ob.get();
ob.totalsalary();
ob.display();

}
}

class employeeinfo
{
Scanner in = new Scanner (System.in);
Scanner ins = new Scanner (System.in);
String name,gender,position;
int id,salary,ma,hr,bn;

void get()
{
System.out.print ("\n\t Enter employee ID = ");
id = in.nextInt();
System.out.print ("\n\t Enter emplyee name = ");
name = ins.nextLine();
System.out.print ("\n\t Enter employee gender = ");
gender = ins.nextLine();
System.out.print ("\n\t Enter employee salary = ");
salary = in.nextInt();
System.out.print ("\n\t Enter employee position = ");
position = ins.nextLine();
}

void totalsalary()
{
System.out.print ("\n\t Enter medical allowance = ");
ma = in.nextInt();
System.out.print ("\n\t Enter house rent = ");
hr = in.nextInt();
System.out.print ("\n\t Enter bounus = ");
bn = in.nextInt();
}

void display()
{
System.out.println ("\n\t Employee ID = "+id);
System.out.println ("\n\t Employee name = "+name);
System.out.println ("\n\t Employee gender = "+gender);
System.out.println ("\n\t Employee basic salary = "+salary);
System.out.println ("\n\t Employee position/post = "+position);
System.out.println ("\n\t Total salary = "+(ma+hr+bn+salary));
}

}



1 comment:

  1. Once you find the right websites then you
    add a link to these websites on your links page and send an individual email
    to each one of these website owners. This item is not as
    comprehensive as their paid versions, but it may well
    provide ongoing assistance if you have a limited budget.
    With a little training you can learn to spot these phonies and pick
    up on the best internet marketing strategies around.
    Also visit my web site review of market samurai

    ReplyDelete