Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need as a Java program and need help with question 2. Thank You! Question 1 23 Points In this question, you will use loops and

Need as a Java program and need help with question 2. Thank You!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Question 1 23 Points In this question, you will use loops and methods to generalize the work you did in Assignment 1. Basically, you will make your Assignment 1's program process an arbitrary number of employee. Moreover, you will use methods modularize your code. Your need to implement the following two methods that will be used in your program: 1. calculate Pay: this method takes two numeric input parameters that represent hourlyPay of type double) and numberOfHours (of type int). The method then calculates and return the employee's pay. Note that the company pays 1.5 for hours above 10 hours. For example, if an employee's hourly pay is 20 and the employee worked 10 hours, then the net pay for that employee is 200 (20*10). On the other hand, if the employee worked 15 hours for the same hourly pay, then the employee's net pay will be 350 (10*20+5*20*1.5). 2. calculateTax: this method takes one double input parameter that represents the employee's pay. The method then calculates and returns the tax to be deducted from that employee using the following rules: a. no tax will be deducted for pay 500 and 1500. Follow the following steps in implement your main method: 1. Ask the use to enter the number of employees to be processed and read this number. 2. Write a loop where the number of iterations is equal to the number of employees and each iteration in the loop does the following: a. Ask the user to enter the employee's hourly rate and read the number. b. Ask the user to enter the employee's hours worked and read the number. C. Call the calculatePay method that returns the employee's pay before tax. d. Use the output that is returned by the calculatePay method as input to calculateTax method to find the tax to be deducted from that employee. e. Print the employee's pay check details. Sample run: Enter number of employees: Employee #1 Hourly rate: 20 Hours: 20 Pay: 500.0 Tax: 0.00 Net pay: 500.00 Employee #2 Hourly rate: 20 Hours: 40 Pay: 1100.0 Tax: 55.00 Net pay: 1045.00 Employee #3 Hourly rate: 30 Hours: 40 Pay: 1650.0 Tax: 115.50 Net pay: 1534.50 Question 2 (22 Points This question is to be completed after Week 5's lecture on February, 14th, 2020. In this question, you need to think about an object that can be used to represent a category of things and implement a class to represent this object. Here are some ideas for objects but you can come up with your own idea if you prefer. To-do List Music album Musical instrument Food You may NOT choose any example I have given you in class nor any class defined in the online textbooks. You will receive 0 POINTS if you use a class that has been given to you by me as an example or that appears in the online textbook. The list of classes you may NOT choose includes, but is not limited to: Car Tree Recipe Invoice Film Requirements 1. Once you decide what is your object, start your program by drawing the UML diagram of your class. Draw the UML on a word document (.doc or .docx) 2. Implement your class and make sure to include all the following: a. Your class must have at least three instance variables and theses instance variables may not all be the same type. For example, your three instance variables cannot all be Strings. b. Write at least two different constructors for your class. c. All instance variables must be private and all methods must be public. d. Write an accessor (getter) method for every data member of the class. e. Write a mutator (setter) method for every data member of the class. f. Implement an equals() method to compare two of your objects. g. Implement a toString() method that converts one of your objects to a String. h. Think of two actions that your object can perform and implement two methods to perform those actions. At least one of these methods must require input parameters and at least one method must return an output. i. Note that, the methods in your class should not do any input or output. Information must be passed through the parameter list or returned from each method by using a return statement. No statements such as nextLine() or println() should appear in the class. 3. Implement a Driver class to test your object. The Driver class contain ONLY a main() method. Write code in the main() method to test your class as follows: a. instantiate a couple of objects b. use each setter and getter method. c. demonstrate the use of equals() and toString(). d. show that your other methods work properly. e. You may do input and output in the main () method. Important notes Your grade for this question depends on the following: Your submission meets all the requirements as described above. The program is robust with no runtime errors or problems. The program must display your name when it runs. Your implementation must include two classes - one for your category of objects and one Driver class to test your object

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions