Application based QUESTIONS for JAVA Q1. Write Java Code for the following a) On the Action event of the close button the application gets closed. 1 b) On the Action event of the clear button all the text fields and the check boxes get cleared. 1 c) On Action event of the button Calc Percentage Net percentage of the student is calculated and displayed in the appropriate text filed. Net percentage is same as that of the actual percentage if the student doesn t opts for NCC otherwise 5% is added to actual percentage. 2 d) On Action Event of the button Result, the application checks the eligibility of the students. And display result in the appropriate text field. Minimum percentage for science is 70, for commerce 60 and for humanities 40. Q2. Mr. Amit developed the following GUI application for Calculating Salary. Help him to write coding for the following
i) Calculate Salary as per the following criteria 2 BASIC PAY=BASIC+GRADE PAY DA= 90% OF BASIC PAY Display the DA in its appropriate textfield. ii) HRA should calculated according to the type of city 2 (Chosen from the listbox) Type of City Percentage TYPE-A 30% OF BASIC PAY TYPE-B 20% OF BASIC PAY TYPE-C 10% OF BASIC PAY GROSS=BASICPAY+DA+HRA Professional tax should be assigned as Rs. 300/- for Teaching Staff and Rs. 0/- for Nonteaching tax NET SALARY= GROSS-PROFESSIONAL TAX Display all calculated values in appropriate text fields. iii) Clear button should clear all text fields. 2 Q3. Blue Valley Public School has computerised its registration for class XI students. Given below is the data entry form for same. Control Controls Description
Name Text field jtextfield1 To accept admission number of the student Text field jtextfield2 To accept Name of the student Text field jtextfield3 To display total fee of the student Radio button joptcom To choose Commerce subject Radio button joptarts To choose Arts subject Radio button joptmed To choose Medical subject Radio button joptnonmed To choose Non Medical subject CheckBox jchkbox To enter information whether the computer is opted Button jbutton1 Button jbutton2 To perform the different tasks which are mentioned Button jbutton3 below. Button jbutton4 Answer the following questions using Java NetBeans IDE: (i) On clicking the initial button the jtextfield1 and jtextfield2 should be set as uneditable. (1) (ii) On clicking the Calculate button the Total Fee is calculated on the basis of the following criteria: Stream Fee(Rs.) Commerce 2500 Arts 2000 Medical 2900 Non-Medical 2800 The Total Fee should be displayed in jtextfield3.(3) (iii) If the student has opted for Computers Rs. 200 will be added to the total fee. The modified Total Fee should be displayedin jtextfield3. (1) (iv) On Clicking the End button the application will be closed.(1)
Q4.A cloth show room has announced the following festival discount on the purchase of items based on the total cost of the item purchased. Total Cost Discount (in percentage) Less than 2000 5% 2001 to 5000 25% 5001-10000 35% Above 10000 50% Design a GUI application to input the total cost and the compute and display the amount to be paid by the customer after availing the discount. 1. Write a method called festival_discount ( ) which calculate net amount after discount The method should total cost as a double type parameter. 3 2.Write the code for calculate button click event procedure to call the festival_discount ( ) method 2 3.Write the code for Exit button. 1 Q5. Ms Pragati works at a Recreation Park as a system analyst. She has created the following GUI. When a group arrives at the Recreation Park, the number of people in the group and whether the group wants to enjoy the Water Park or not is entered. Entry fees is < 500 per person. The person can choose to play at Water Park by selecting the checkbox. Rides of Water Park will cost 250 per person. Help her to write code for the following : 3 (i) On the click of command button Calculate, textfield for Entry Fees should display Number of people. Textfield for Total Amount should display sum of Entry Fees and Water Park Charges for all the people in the group. (ii) Write Java code to clear all Textboxes on the click of Clear button. 1
(iii) Write Java code to close the application on the click of Exit button. 1 Q6. Read the following case study and answer the questions that follow : The Shop n Store has developed the following data entry screen for its operations. The store offers three different types of membership discount schemes for its regular customers. Platinum members get a discount of 10% on all their purchases, Gold members get 5% and Silver members get 3% discount. The list of controls for above interface is as follows: Object Type Text Field Radio Buttons Button Object Name ProducTF QtyTF RateTF AmountTF DiscountTF NetTF PlatinumRB GoldRB SilverRB CalcBTN ExitBTN Description To enter name of the product To enter quantity Sold To enter rate per unit To display total amount as quantity *rate To display the discount amount based on membership type To display net amount as amount-discount To Specify the Member Ship Type To Calculate the amount, discount and net amount To Close the Application (i). Write the code to disable the text fields AmountTF, DiscountTF and NetTF. [1] (ii). Write the code for CalcBTN to calculate the amount, discount and net amount as per given [2] descriptions and conditions. (iii).write the code for ExitBTN to close the application, but before the application is closed it should check the net amount and if the net amount > 10,000 the membership of the customer should be upgraded and displayed. For example, if the customer already has Silver membership it should be upgraded Gold membership (similarly from gold to platinum) and he informed of the same using a message box. Q7.Read the following case study and answer the questions that follow : The Shop n Store has developed the following data entry screen for its operations. The store offers three different types of membership discount schemes for its regular customers. Platinum
members get a discount of 10% on all their purchases, Gold members get 5% and Silver members get 3% discount. Marks Grade % > = 90 A++ 80-90 A+ 75-80 A 60-75 B 50-60 C 40-50 D <40 Fail The list of controls for above interface is as follows: (i). Write the code to disable the text fields AmountTF, DiscountTF and NetTF. [1] (ii). Write the code for CalcBTN to calculate the amount, discount and net amount as per given [2] descriptions and conditions (iii).write the code for ExitBTN to close the application, but before the application is closed it [2] should check the net amount and if the net amount > 10,000 the membership of the customer should be upgraded and displayed. For example, if the customer already has Silver membership it should be upgraded Gold membership (similarly from gold to platinum) and he informed of the same using a message box. Q8.Design a GUI application having interface as shown below. 2+2+1=5 (i) The percentage marks are to be entered in the Text field(markstf) and upon clicking at a button(calcbtn), corresponding grade (as per following rules) should be displayed in the label(resultlbl) below command button. Grade Calculator Enter your marks% 82 Calculate Final Grade You get on A+ (ii) Write the code for FocusLost event of texfield markstf to ensure that the user does not enter a negative or zero value. If a negative or a zero value is entered, then the textfield should be made blank and a warning message should be displayed. (iii) If you are asked to add a clear button to the application, what code would your write for it so that the textifield markstf and label resultlbl get cleared when it is clicked?
Q9.Mr. Madhav works in a construction company. To calculate total wages he has developed the following GUI in NetBeans. Male and female labourers are respectively paid Rs. 150/- per day and Rs. 170/- per day. Skilled labourers are paid extra at the rate of Rs. 100/- day. Male and female labourers from rural areas are paid 10% less per day. You may choose any valid name for control name and variable name. Write code to do the following- (i) When Calculate Wage button is clicked, the total wages is calculated as per the given criteria and displayed in total wage text box. [3] (ii) When Clear button is clicked, all the text boxes should be cleared and radio button, check box should be deselected. [1] (iii) Close the application when Quit button is pressed. [1] Q10.Suresh is an employer in Electricity board. He has developed the following GUI to calculate the electricity bill. Slab for units consumed Units Domestic Commercial 0-300 Rs. 2/- per unit Rs. 5/- per unit
>300 Rs. 4/- for units Rs. 10/-per units For eg: if units consumed for domestic purpose is 650 then Upto 300 units :Rs. 600/- Above 300 units: Rs. 1400/- Net Amount: Rs. 2000/- (1) Which method is used to determine whether domestic or commercial radio button is been clicked or not? (1) (2) Write code for the following a) Calculate and display amount upto 300 units, above 300 units and net amount when Calculate button is clicked. (3) b) Clear all the text fields when clear button is clicked (1) c) Close the application when stop button is clicked.(1) ********************************************