QUESTION 1 (15 MARKS) Given the template of a class named Employee as follows: public class...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
QUESTION 1 (15 MARKS) Given the template of a class named Employee as follows: public class Employee { } private String id; private String name; private double sales Amount; //Methods: //constructors, mutators, accessors, processor, //toString() a) Write the following method definition: i) Normal constructor for the Employee class. ii) Accessor for attribute id for the Employee class. (1 mark) iii) Processor method named calBonus () that calculates and returns the bonus based on the sales amount. The following table shows the bonus. Bonus (RM) Sales amount (RM) 0 - 1000 >1000-2500 >2500 CONFIDENTIAL Hak Cipta Universiti Teknologi MARA 0 ii) Display the employee information using the toString() method. 200 300 b) Write the following statement(s) in the main program: i) Construct an object of Employee named employee using the normal constructor. Assign "1002" for id, "ali" for name, and 1500 for salesAmount. 9 (2 marks) (4 marks) (2 marks) (2 marks) CONFIDENTIAL CS/JUL 2022/CSC435 iii) Check if the employee will receive any bonus using the processor. Print "Congrats, you will receive RMXXX" where XXX is the bonus amount if the employee will receive any bonus. Otherwise, print "Work harder next month". (4 marks) QUESTION 1 (15 MARKS) Given the template of a class named Employee as follows: public class Employee { } private String id; private String name; private double sales Amount; //Methods: //constructors, mutators, accessors, processor, //toString() a) Write the following method definition: i) Normal constructor for the Employee class. ii) Accessor for attribute id for the Employee class. (1 mark) iii) Processor method named calBonus () that calculates and returns the bonus based on the sales amount. The following table shows the bonus. Bonus (RM) Sales amount (RM) 0 - 1000 >1000-2500 >2500 CONFIDENTIAL Hak Cipta Universiti Teknologi MARA 0 ii) Display the employee information using the toString() method. 200 300 b) Write the following statement(s) in the main program: i) Construct an object of Employee named employee using the normal constructor. Assign "1002" for id, "ali" for name, and 1500 for salesAmount. 9 (2 marks) (4 marks) (2 marks) (2 marks) CONFIDENTIAL CS/JUL 2022/CSC435 iii) Check if the employee will receive any bonus using the processor. Print "Congrats, you will receive RMXXX" where XXX is the bonus amount if the employee will receive any bonus. Otherwise, print "Work harder next month". (4 marks)
Expert Answer:
Answer rating: 100% (QA)
a Method definitions public class Employee private String id private Str... View the full answer
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
Which of the following explains the mechanism of inhalation? An increase in temperature inside the lungs allows for more oxygen to enter the lungs. An increase in atmospheric pressure creates a...
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
You are the CEO of Green Paper Inc., a producer of high-end printing paper with an emphasis on environmentally friendly "green" production methods. One of your employees has proposed a significant...
-
A diving bell in the shape of a cylinder with a height of 2.00 m is closed at the upper end and open at the lower end. The bell is lowered from air into sea water (= 1025 kg/m3). The air in the bell...
-
This exercise continues the Lawlor Lawn Service, Inc., situation from Exercise 3-48 of Chapter 3. Start from the posted T-accounts and the adjusted trial balance for Lawlor Lawn Service prepared for...
-
Correlation between height and weight for players on the 2014 Brazil World Cup Team, using data from all 23 players on the roster. State whether the quantity described is a parameter or a statistic...
-
Granger Supermarkets (GS) operates at capacity and decides to apply ABC analysis to three product lines: baked goods, milk and fruit juice, and frozen foods. It identifies four activities and their...
-
Helix Corporation uses the weighted - average method in its process costing system. It produces prefabricated flooring in a series of steps carried out in production departments. All of the material...
-
Given the following sketches, generate an Excel spreadsheet: 1) Count the total degrees of freedom in the sketch. 2) Count the constraints 3) Provide the number of dimensions that are necessary to...
-
A lifeguard needs to rope off a rectangular swimming area in front of Long Lake Beach, using 600 yd of rope and floats. What dimensions of the rectangle will maximize the area? What is the maximum...
-
The prefrontal lobotomy is a drastic and largely procedure used to disconnect that portion of the cerebral cortex from the rest of the frontal lobe and the diencephalon as a psychiatric therapy. What...
-
There are three elements to an organization: structure, purpose, and activities. The criminal justice system is comprised of many interconnected organizations. Describe the three elements as they...
-
a. What's more? 1. Military title 2. Temperature in degree Celsius 3. Birthplace 4. Year level ACTIVITY 5: Label it! Directions: On the space provided before the number, write I if the variable is...
-
Question which is thought of as an overarching system of formal and informal relationships within which the firm participates to procure, transform and enhance, and ultimately supply its offerings in...
-
Which of these constructions was made possible through the Roman use of concrete as building material? W 3
-
A transmilenium feeder has stopped at a traffic light, starts moving and increases its speed uniformly up to 70 km / h after 10 s. From that moment on, the speed remains constant for 0.25 minutes,...
-
Distinguish between the work performed by public accountants and the work performed by accountants in commerce and industry and in not-for-profit organisations.
-
Modify the program of Fig. 17.22 to summarize the number of occurrences of every character in the file. Fig. 17.22 1 // Fig. 17.22: StreamOfLines.java 2 // Counting word occurrences in a text file. 4...
-
A website only lets users set a password if the the password contains between 8 and 15 characters, starts with an alphabet, contains at least one uppercase letter, and contains at least one number....
-
Write an application based on the application in Exercise 14.11 that inputs a line of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet...
-
Explain how corporations provide limited liability to their owners.
-
Why do administrative agencies grow over time? Explain.
-
Explain the steps in the informal rulemaking process.
Study smarter with the SolutionInn App