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
111 views
in Computer by (41.5k points)
closed by

Vijay has developed software for planning personal budget. A screenshot of the same is shown below:

Total Income, Expenses of Bills (Water/Electricity), Groceries, Entertainment, other expenses and whether money is to be sent to Hostel are entered by the user. Sum of Expenses, Grand Total of Expenses and Savings are calculated and displayed by the program. Write the code to do the following:

When ‘CALCULATE’ button is clicked, Sum of Expenses, Total Expenses and Savings should be calculated and displayed in appropriate text fields.

  • Sum of Expenses is calculated by adding expenses on Bills(Water/Electricity), Groceries, Entertainment other expenses.
  • Grand Total of Expenses is calculated according to the following criteria: If ‘Money to be sent to Hostel’ checkbox is selected, 3000.00 is to be added to the sum of expenses. If it is not selected, Grand Total of Expenses is the same as sum of expenses.
  • Savings = Total Income – Grand Total of Expenses.

1 Answer

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

//Calculation of Sum of Expenses 

jTextField6.setText("" + 

Integer.parseInt(jTextField2.getText()+ 

Integer.parseInt(jTextField3.getText()+ 

Integer.parseInt(jTextField4.getText()+ 

Integer.parseInt(jTextField5.getText()); 

//Calculation of Grand Total of Expenses 

if(jCheckBox1.isSelected()) 

jTextField7.setText("" + 3000 + 

Integer.parseInt(jTextField6.getText())); 

else 

jTextField7.setText("" + 

Integer.parseInt(jTextField6.getText())); 

// Calculation of Savings 

jTextField8.setText(“” + 

Integer.parseInt(jTextField1.getText()) Integer.

parseInt(jTextField7.getText()));

(ii) When ‘CLEAR’ button is clicked, all text fields and checkbox should be cleared. 

jTextField1.setText(""); 

jTextField2.setText(""); 

jTextField3.setText(""); 

jTextField4.setText(""); 

jTextField5.setText(""); 

jTextField6.setText(“”); 

jTextField7.setText(""); 

jTextField8.setText(“”); 

jCheckBox1.setSelected(false); 

(iii) When ‘CLOSE’ button is clicked, the application should close. System.exit(0);

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

...