This document contains instructions for a midterm exam in a Java class. It has 3 questions worth a total of 30 marks: (1) Explain fall through in switch statements with an example (5 marks), (2) Write an Employee class with methods to get info, add salary if less than 500, and add to salary if hours are over 6 (15 marks), (3) Write an Area class to print the area of a rectangle with width and height, and a square with one side, asking the user for values (10 marks).
This document contains instructions for a midterm exam in a Java class. It has 3 questions worth a total of 30 marks: (1) Explain fall through in switch statements with an example (5 marks), (2) Write an Employee class with methods to get info, add salary if less than 500, and add to salary if hours are over 6 (15 marks), (3) Write an Area class to print the area of a rectangle with width and height, and a square with one side, asking the user for values (10 marks).
This document contains instructions for a midterm exam in a Java class. It has 3 questions worth a total of 30 marks: (1) Explain fall through in switch statements with an example (5 marks), (2) Write an Employee class with methods to get info, add salary if less than 500, and add to salary if hours are over 6 (15 marks), (3) Write an Area class to print the area of a rectangle with width and height, and a square with one side, asking the user for values (10 marks).
1. What is a fall through in switch? Explain it with an example. (05) 2. Write a class named “Employee” having following methods (15) • ‘GetInfo ()’ which adds the salary, number of hours of work per day of employee as parameter. • ‘AddSal ()’ which adds 10 rupees to salary of the employee if its salary is less than 500 rupees. • ‘AddWork ()’ which adds 5 rupees to salary of employee if the number of hours of work per day is more than 6 hours. 3. Write a class named Area to print the area of Rectangle and Square. The method which will print the area of a rectangle will have two parameters i.e. Width and Height. While the method to print the area of a Square will only have one parameter which will be the one side only. And Ask user to enter the values separately. (10)