Hilan International Bank decided to have a salary plan for its employees. In the new Policy, bonus is based on the fact that one is a senior staff or junior staff. You have been called in as a programmer to develop a software to meet this policy’s requirement:
(a.) Create a class called Salary.
(b.) Create methods/functions that will calculate
i. the tax which is 5% of the gross salary
ii. Bonus depending on the status of employee-senior/junior
Senior staff-1hr-15 US dollars
Junior staff-1hr-12 US dollars
iii. Net Salary=Bonus+gross salary-tax
(c.)Create another class called SalDemo with the main function
(d.)Declare an instance of the salary class called cal.
(e.)Use the cal object to check the net salary
(f.)Use JOptionPane to allow a user to enter the status, time and the gross salary.


import javax.swing.JOptionPane;
 class salary{
 	String status;
 	double T;   //T represents time.
 	double gross_salary;
 	double bonus;
 	double GetTax(double gross_salary){
 		double tax=gross_salary*0.05;
 		return tax;
 	double GetBonus(double T,String status){
 			if(status=="senior staff"){
 			double bonus=T*15;
 		         else if(status=="junior staff"){
 				return bonus;
 	double GetNetSalary(double bonus,double gross_salary,double tax){
 		double netSalary=(bonus+gross_salary)-tax;
 		return netSalary;
 class SalDemo{
 	public static void main(String args[]){
 		salary cal = new salary();
 		String T=JOptionPane.showInputDialog("Enter time");
 		double time=Double.parseDouble(T);
 		String status=JOptionPane.showInputDialog("Enter status");//where st represent status.
 		String st=String.parseString(status);
 		String g_salary=JOptionPane.showInputDialog("Enter gross salary");
 		double gross_salary=Double.parseDouble(g_salary);
 		JOptionPane.showMessageDialog(null,"Your Net salary is ="+cal.GetNetSalary

Edited by Nick Evan: Added CODE tags

6 Years
Discussion Span
Last Post by masijade

Because there is no parseString method in String. Simply assign the provided String to the new variable. The API docs are your friend, BTW. Ask them first.

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.