jamseerabeegam
java
1 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners

Create an Employee class which has methods netSalary which would accept salary & tax as arguments & returns the netSalary which is tax deducted from the salary. Also it has a method grade which would accept the grade of the employee & return grade.

Ads

View Answers

December 23, 2010 at 11:09 AM


Hi Friend,

Try the following code:

import java.util.*;
class  Employee
{
    static Scanner input=new Scanner(System.in);
    public double netSalary(double salary, double taxrate){
    double tax=salary*taxrate;
    double netpay=salary=tax;
    return netpay;
}
public static String grade( ){
    System.out.print("Enter Grade: ");
    String grade=input.next();
    return grade;
}
    public static void main(String[] args){
        Employee emp=new Employee();
        System.out.print("Enter Salary: ");
        double sal=input.nextDouble();
        System.out.print("Enter Tax in %: ");
        double taxrate=input.nextDouble()/100;
        System.out.println("Net Salary is: "+net);
        String g=emp.grade();
        double net=emp.netSalary(sal,taxrate);
        System.out.println("Grade is: "+g);
    }
}

Thanks










Related Tutorials/Questions & Answers:
java
java  diff bt core java and java
java
java  what is java
Advertisements
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
Java
Java   Whether Java is pure object oriented Language
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  give a simple example for inheritance in java
java
java  give a simple example for inheritance in java
Java
Java  how to do java in command prompt
java
java  Does java allows multiline comments

Ads

Advertisement