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
-
Examine the table below that summarizes the income, and cost data for five companies. Use the information to fill in the values in the lower half of the table. Which company is making the most...
-
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 drug company maintains that a new drug G for a certain disease has a 50% cure rate as compared with drug H, which has only a 25% cure rate You are asked to design a clinical trial comparing drugs G...
-
A mean square is the same as what type of descriptive statistic?
-
The study that determines whether a project can be completed in an acceptable time frame is: a. a schedule feasibility study. b. a technical feasibility study. c. an operational feasibility study. d....
-
Usury laws place a ceiling on interest rates that lenders such as banks can charge borrowers. Why would we expect low-income households in states with usury laws to have significantly lower levels of...
-
Assuming a 12% annual interest rate, determine the present value of a five-period annual annuity of $6,800 under each of the following situations: (EV of $1. PV of $1. EVA of $1. PVA of $1. EVAD of...
-
1. Clearly, if Fitz-Simmons clientele have good supplier relationships, they have worked at supplier development. If they want to maintain those relationships with their suppliers, what are some...
-
Assume a company is considering whether to accept or reject a special order opportunity to sell a customer 300 units of a slightly customized version of one of its products for $40.75. The normal...
-
Explain how special journals are posted.
-
The client of a CPA is a partnership. The drawings of the managing partner are considerably in excess of the partner's pro rata share of earnings. Other partners are not aware of the excess drawings...
-
Explain how transactions recorded in the sales journal and the cash receipts journal are posted.
-
How does journalising differ from posting?
-
Lerna Corporation (whose fiscal year will end December 31, 19X8) informs you on December 18, 19X8 that it has a serious shortage of working capital because of heavy operating losses incurred since...
-
According to lecture, in social psychology the imagined presence of others ___________. is not applicable because social psychology is a scientific discipline only applies to delusional people never...
-
The unadjusted trial balance of Secretarial Services is as follows: SECRETARIAL SERVICES Unadjusted Trial Balance as at 31 December 2017 Account Debit Credit Cash at bank Office supplies Prepaid...
-
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...
-
In the U.S. the Federal Bureau of Investigation (FBI) uses a Uniform Crime Reporting (UCR) system to track violent crimes (like murder) and property crimes (such as theft of motor vehicles or...
-
Assume that you own and manage a small clothing store. A. What kinds of financial information would you want to run your business? B. What kinds of nonfinancial information would you want (for...
-
One of the first U.S. major industries to be regulated was the railroads. Farmers and manufacturers depended on railroads to get their products to market, and often there was only one railroad...
Study smarter with the SolutionInn App