Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
94 views
in Computer by (41.5k points)
closed by

Mr. Pawan works as a programmer in “ABC Marketing Company” where he has designed a Salary generator software to generate the salary of salesman in which Name and Salary are entered by the user. A screenshot of the same is shown below:

Help him in writing the code to do the following:

I.) After selecting appropriate Radio Button, when ‘Commission’ button is clicked, commission should be displayed in the respective text field as each Salesman will get a commission based on the units sold according to the following criteria:

Units sold Commission(in Rs.)
1-20 500
20-40 100
>4 2000

ii) When ‘Gross Salary’ button is clicked, Gross Salary should be calculated and displayed in the respective text field as per the given formulae: 

Gross Salary= Salary+Commission

iii) After required selection of Checkbox(es), when ‘Facility Charges’ button is clicked, Facility charges will be displayed in the respective text field according to the following criteria:

Facility Charges
Transport 500
Mess 2000

iv) Money will be deducted from the Gross Salary according to the facilities opted by the employee. 

When ‘Net Salary’ button is clicked, Net Salary should be calculated and displayed in the respective text field as per the given formulae: 

Net Salary= Gross Salary-Deductions

1 Answer

+1 vote
by (47.1k points)
selected by
 
Best answer

i) Code to calculate and display commission: 

int com=0; 

if(jRadioButton1.isSelected()) 

com=500; 

else if(jRadioButton2.isSelected()) 

com=1000; 

else if(jRadioButton3.isSelected()) 

com=2000; 

jTextField3.setText(“”+com);

ii) Code to calculate and display Gross Salary: 

int sal,comm; 

sal=Integer.parseInt(jTextField2.getText()); 

comm=Integer.parseInt(jTextField3.getText()); 

jTextField4.setText(“”+(sal+comm));

iii) Code to calculate and display charges for the facilities: 

int extra=0; 

if(jCheckBox1.isSelected()) 

extra=extra+500; 

if(jCheckBox2.isSelected()) 

extra=extra+2000; 

jTextField5.setText(“”+extra);

iv) Code to calculate and display the Net Salary 

int amt,extra; 

amt=Integer.parseInt(jTextField4.getText()); 

extra=Integer.parseInt(jTextField5.getText()); 

jTextField6.setText(“”+(amt-extra));

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...