Search This Blog

UI/UX Design | Web Development | Mobile Application Development

Whether you need UI/ UX design, web development services, or mobile app development services, Qaabil Digitals will be more than happy to help you. We work with top software developers, designers, and project managers. We tailor our services to suit your exact needs. We closely look at your company, listen to your story, and bring about the best ideas and solutions that can help you drive solid results. We don’t just produce work that works. We produce work that matters. Get a quote now Or Talk to us

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));
}

}



18 comments:

  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
  2. Create a class Employee with the following private member variables.

    int employeeId
    String employeeName
    double salary
    double netSalary
    Include appropriate getters and setters method in Employee class. Write the following method in the Employee class:
    public void calculateNetSalary(int pfpercentage) - This method should take PF percentage as argument. Deduct the PF amount from the salary and set the netSalary.


    Create a Main class which has the main method which invokes the method to get the input and prints the details as shown in the sample.

    Also write a method :

    public static Employee getEmployeeDetails() - which gets the employee details and returns the employee object.

    public static int getPFPercentage() - which gets the PF percentage and returns the same

    Sample Input 1:

    Enter Id:
    101
    Enter Name:
    Vivek
    Enter salary:
    20000
    Enter PF percentage:
    7

    Sample Output 1:

    Id : 101

    Name : Vivek

    Salary : 20000.0

    Net Salary : 18600.0


    ReplyDelete
    Replies
    1. can I know the code for this please

      Delete
    2. Heya! can you please help me in this...

      Delete
  3. Guys help me in my project to create a prothat computes a salary from employees and deduct absence

    ReplyDelete
  4. public static Employee getEmployeeDetails() - which gets the employee details and returns the employee object.

    ReplyDelete
  5. Create a class Employee with the following private member variables.

    int employeeId
    String employeeName
    double salary
    double netSalary
    Include appropriate getters and setters method in Employee class. Write the following method in the Employee class:
    public void calculateNetSalary(int pfpercentage) - This method should take PF percentage as argument. Deduct the PF amount from the salary and set the netSalary.


    Create a Main class which has the main method which invokes the method to get the input and prints the details as shown in the sample.

    Also write a method :

    public static Employee getEmployeeDetails() - which gets the employee details and returns the employee object.

    public static int getPFPercentage() - which gets the PF percentage and returns the same

    ReplyDelete
    Replies
    1. Did you get the code?
      I need hepl..

      Delete
    2. //Class Employee:


      public class Employee
      {
      private int employeeId;
      private String employeeName;
      private double salary;
      private double netSalary;
      static int pfpercentage;

      public int getEmployeeId()
      {
      return employeeId;
      }
      public void setEmployeeId(int employeeId)
      {
      this.employeeId=employeeId;
      }

      public String getEmployeeName()
      {
      return employeeName;
      }
      public void setEmployeeName(String employeeName)
      {
      this.employeeName=employeeName;
      }

      public double getSalary()
      {
      return salary;
      }
      public void setSalary(double salary)
      {
      this.salary=salary;
      }
      public double getNetSalary()
      {
      return netSalary;
      }
      public void setNetSalary(double netSalary)
      {
      this.netSalary=netSalary;
      }


      public void calculateNetSalary(int pfpercentage)
      {
      this.pfpercentage=pfpercentage;
      double deduct=(salary*pfpercentage)/100;
      netSalary=salary-deduct;
      }

      public void display()
      {
      System.out.println("Id : " +employeeId);
      System.out.println("Name : " +employeeName);
      System.out.println("Salary : " +salary);
      System.out.println("NetSalary :" +netSalary);
      }
      }



      //Class Main:

      import java.util.Scanner;

      public class Main
      {

      static int pfpercentage;
      public static Employee getEmployeeDetails()
      {
      Employee em=new Employee();
      System.out.println("Enter Id:");
      em.setEmployeeId(101);
      System.out.println("Enter Name:");
      em.setEmployeeName("Vivek");
      System.out.println("Enter salary:");
      em.setSalary(20000);
      System.out.println("Enter PF percentage");
      em.calculateNetSalary(getPFPercentage());
      em.display();
      return em;
      }

      public static int getPFPercentage()
      {
      Scanner sc=new Scanner(System.in);
      pfpercentage=sc.nextInt();
      return pfpercentage;
      }

      public static void main(String[] args)
      {
      getEmployeeDetails();
      }


      }

      Delete
  6. Create a class Person with the following private member variables

    String name
    char gender
    int age
    Include appropriate getters and setters method

    Create a class BusTicket with the following private member variables

    int ticketNo
    float ticketPrice
    float totalAmount
    Person person
    Include appropriate getters and setters method

    Write the following method in the BusTicket class
    void calculateTotal()—this method should calculate the total and set it based on the discount given below:

    For Children whose age is less than 16, give 50% discount
    For Senior citizen whose age is greater than or equal to 60 give 25% discount
    For Ladies give 10% discount
    No discount for remaining category.
    Based on above condition calculate total price.

    Create TestMain class which has main method and do the following input and output process .

    To get the input write a method

    public static BusTicket getTicketDetails() - Get the inputs relevant to BusTicket in this method and return the BusTicket object. Call this method in the main method, using the returned object invoke the method calculateTotal and print the output accordingly

    Sample input 1:

    Enter the passenger name:
    vivek
    Enter the gender(M or F / m or f):
    M
    Enter the age:
    16
    Enter the ticket no:
    123
    Enter the ticket price:
    100.0

    Sample Output 1

    Ticket no:123
    Passenger Name:vivek
    Price of a ticket : 100.0
    Total Amount : 100.0



    Sample input 2:
    Enter the passenger name:
    Priya
    Enter the gender(M or F / m or f):
    F
    Enter the age:
    61
    Enter the ticket no:
    140
    Enter the ticket price:
    500.0

    Sample Output 1

    Ticket no:143
    Passenger Name:Priya
    Price of a ticket : 500.0
    Total Amount : 375.0

    ReplyDelete
  7. Did you got this code?
    I need help.

    ReplyDelete
    Replies
    1. please help me with the code for the question

      Delete
  8. This comment has been removed by the author.

    ReplyDelete
  9. /* Write a class name employee. This class should hold the employee's
    details such as employee id,name,gender,salary. 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 */

    import java.util.*;

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

    void get(){
    System.out.print("\n\t id:- ");
    id=sc.nextInt();
    System.out.print("\n\t name:- ");
    name=sc.next();
    System.out.print("\n\t salary:- ");
    salary=sc.nextFloat();
    }
    void totalsalary(){
    System.out.print ("\n\t Enter medical allowance = ");
    ma = sc.nextInt();
    System.out.print ("\n\t Enter house rent = ");
    hr = sc.nextInt();
    System.out.print ("\n\t Enter bounus = ");
    bn = sc.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 basic salary = "+salary);
    System.out.println ("\n\t Total salary = "+(ma+hr+bn+salary));
    }
    }

    class employee{
    public static void main(String args[])
    {
    Scanner sc=new Scanner(System.in);
    employeeinfo ei=new employeeinfo();
    int number,i;

    System.out.println("Enter the Howmany employee:-"); //Howmany employee U get
    number = sc.nextInt();
    for(i=1;i<=number;i++){
    System.out.println("------------Input-Data------------");
    ei.get();
    ei.totalsalary();
    System.out.println("------------OutPut-Data-----------");
    ei.display();
    }


    }
    }

    ReplyDelete
  10. how to use column and raw span in formation of table

    ReplyDelete
  11. Create a class Person with the following private member variables

    String name
    char gender
    int age
    Include appropriate getters and setters method
    Create a class BusTicket with the following private member variables

    int ticketNo
    float ticketPrice
    float totalAmount
    Person person
    Include appropriate getters and setters method

    Write the following method in the BusTicket class
    void calculateTotal()—this method should calculate the total and set it based on the discount given below:

    For Children whose age is less than 16, give 50% discount
    For Senior citizen whose age is greater than or equal to 60 give 25% discount
    For Ladies give 10% discount
    No discount for remaining category.
    Based on above condition calculate total price.
    Create TestMain class which has main method and do the following input and output process .

    To get the input write a method

    public static BusTicket getTicketDetails() - Get the inputs relevant to BusTicket in this method and return the BusTicket object. Call this method in the main method, using the returned object invoke the method calculateTotal and print the output accordingly

    Note: Define all the attributes as private and methods as public.

    Sample input 1:

    Enter the passenger name:
    vivek
    Enter the gender(M or F / m or f):
    M
    Enter the age:
    16
    Enter the ticket no:
    123
    Enter the ticket price:
    100.0

    Sample Output 1

    Ticket no:123
    Passenger Name:vivek
    Price of a ticket : 100.0
    Total Amount : 100.0



    Sample input 2:
    Enter the passenger name:
    Priya
    Enter the gender(M or F / m or f):
    F
    Enter the age:
    61
    Enter the ticket no:
    140
    Enter the ticket price:
    500.0

    Sample Output 1

    Ticket no:143
    Passenger Name:Priya
    Price of a ticket : 500.0
    Total Amount : 375.0

    need a code for this problem

    ReplyDelete
  12. Q)
    Write a class employee that contain following attributes.
    -name of employee
    - phone number
    - designation
    - job type ( parmenant or daily wages)
    Class also contain following method
    - intilize the following attributes
    -by using method overloading .1st display function display all data related to parmenant employee( name,phone number,designation,monthly salary,bonus, yearly salary,extra working hour)
    - 2nd display function display all data related to daily wages employee(name,ph#,designation,total working hour,total wages)

    Create a child class of employee class "parmenant employee class" and "daily wages employee"
    Child classes contains following attribute
    Parmenant employee / daily wages employee
    - monthly salary / monthly wages
    - extra working hour / total working hour
    - annual salary
    - bonus( paramenant, daily wages employee)
    Member function
    - that calculate salary / calculate daily wages monthly income.
    (Note : object passing in display function.
    Enter data for 5 parmenant employee and 5 daily wages employee)

    ReplyDelete

Share