1,105,578 Community Members

this is the error i get: cannot find symbol method parseString(java.lang.String)

Member Avatar
elcliff
Newbie Poster
2 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

solution

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"){
 				 bonus=T*12;
 				 }		
 				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);
 		System.out.println(cal.GetTax(gross_salary));
 		System.out.println(cal.GetBonus(time,status));
 		System.out.println(cal.GetNetSalary(cal.GetBonus(time,status),gross_salary,(cal.GetTax(gross_salary))));
 		JOptionPane.showMessageDialog(null,"Your Net salary is ="+cal.GetNetSalary
 			(cal.GetBonus(time,status),gross_salary,(cal.GetTax(gross_salary))));
 	}
 }
Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

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.

Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

cross-posted and all because someone can't use five minutes to read the API docs, but will spend days waiting on someone else to read it for him.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article