Computer Science, asked by swagat18, 9 months ago

Answer this, no spam, if spam is observed, you will be reported immediately. Thanks, This is a JAVA program which can be written in BLUEJ window if possible try to define different methods as given...

Attachments:

Answers

Answered by Oreki
2

import java.util.Scanner;  

public class Staff_sal {

String name,

       staffno;

 int basic;

float grossSalary,  

      netSalary;

Saff_sal( ) {

 name = staffno = "";

 basic = 0;

}

 

void acceptDetails( ) {

 Scanner sc = new Scanner(System.in);

 System.out.print("Enter -\n Name - ");

 name = sc.nextLine( );

 System.out.print(" Staff no. - ");

 staffno = sc.nextLine( );

 System.out.print(" Basic Salary - ");

 basic = sc.nextInt( );

}

void compute( ) {

 float da = basic * 0.3f,

       hra = basic * 0.15f,

       pf = basic * 0.12f;

 grossSalary = hra + da + basic;

 netSalary = gross - pf;

}

void display( ) {

 System.out.println("Name - " + name);

 System.out.println("Staff no. - " + staffno);

 System.out.println("Gross Salary - " + grossSalary);

 System.out.println("Net Salary - " + netSalary);

}

public static void main(String[ ] args) {

 Staff_sal employee = new Staff_sal( );

 employee.acceptDetails( );

 employee.compute( );

 employee.display( );

}

}

Similar questions