
write a program to calculate the gross salary and net salary of an employee based on the following attributes: empno,empname,emp address,basic,hra,da,ta,vehicle loan,personel loan use the scanner class....using constructor.pls send program...

Hi Friend,
Try this:
import java.util.*;
class Salary{
int empno;
String empname;
String empaddress;
int basic;
int hra;
int da;
int ta;
int loan1;
int loan2;
Salary(int empno,String empname,String empaddress,int basic,int da,int ta,int hra,int loan1,int loan2){
this.empno=empno;
this.empname=empname;
this.empaddress=empaddress;
this.basic=basic;
this.da=da;
this.ta=ta;
this.hra=hra;
this.loan1=loan1;
this.loan2=loan2;
}
public void get(){
int gp=basic+da+ta+hra;
System.out.println("Gross Pay is: "+gp);
int deductions=loan1+loan2;
int np=gp-deductions;
System.out.println("Net Pay is: "+np);
}
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter empno: ");
int no=input.nextInt();
System.out.println("Enter name: ");
String name=input.next();
System.out.println("Enter address: ");
String address=input.next();
System.out.println("Enter basic pay: ");
int basic=input.nextInt();
System.out.println("Enter da: ");
int da=input.nextInt();
System.out.println("Enter ta: ");
int ta=input.nextInt();
System.out.println("Enter hra: ");
int hra=input.nextInt();
System.out.println("Enter vehicle loan: ");
int loan1=input.nextInt();
System.out.println("Enter personal loan: ");
int loan2=input.nextInt();
Salary sal=new Salary(no,name,address,basic,da,ta,hra,loan1,loan2);
sal.get();
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.