Write code for Employee class. Assume the following code is given. class Employee ( private int...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write code for Employee class. Assume the following code is given. class Employee ( private int id; private String name; private int age: // employee id // employee name // employee age public int getAge() { return age; } // return age // In (a) and (b) below, you need to write 2 methods // for the Employee class here (a) Write a constructor method with no input arguments for the Employee class. Set the default id to 0, the default name to "Unknown", the default age to 1. Show the method header clearly. // write your code here (b) Write the set() method for the Employee class (see header below); set id to newID, name to new Name, age to newAge. You must check that newAge is > 0. If newAge is not in the correct range, print an error message and return immediately, without changing any of the member variables of the Employee object. void set(int newID, String newName, int newAge) // your code go here 1 Write code for Employee class. Assume the following code is given. class Employee ( private int id; private String name; private int age: // employee id // employee name // employee age public int getAge() { return age; } // return age // In (a) and (b) below, you need to write 2 methods // for the Employee class here (a) Write a constructor method with no input arguments for the Employee class. Set the default id to 0, the default name to "Unknown", the default age to 1. Show the method header clearly. // write your code here (b) Write the set() method for the Employee class (see header below); set id to newID, name to new Name, age to newAge. You must check that newAge is > 0. If newAge is not in the correct range, print an error message and return immediately, without changing any of the member variables of the Employee object. void set(int newID, String newName, int newAge) // your code go here 1
Expert Answer:
Answer rating: 100% (QA)
The Below is the code for the Employee class with the requested constructor and set method pub... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
The fixed budget for 21,300 units of production shows sales of $468,600; variable costs of $63,900; and fixed costs of $143,000. The company's actual sales were 26,300 units at $531,600. Actual...
-
Find the values of the parameter p > 0 for which the following series converge. k=1 k ^ ( + In k + 1/ P
-
Explain why studies of the "if-then" variety are considered to be causal studies.
-
In a cylindrical fuel rod of a nuclear reactor, heat is generated internally according to the equation Calculate the temperature drop from the centerline to the surface for a 2.5-cm-diameter rod...
-
As you have seen in this chapter, international trade law is founded on the importance and benefits of removing trade barriers. However, WTO rules also recognize the need to restrain trade in certain...
-
Jokan contributes a non-depreciable asset to the Mahali LLC in exchange for a one-fourth (25%) interest in the capital, profits, and losses of the LLC. The asset has an adjusted tax basis to Jokan...
-
18.A sine wave is travelling in a medium. The minimum distance between the two particles, always having same speed, is (1) (2)
-
6.2. Data has been collected from a chemical reactor. The inlet concentration was the only input variable that changed when the data was collected. The input and output data is given in Table Q6.2....
-
What are the Effects Of COVID-19 on Business
-
A 20 kg dog requires treatment with ketoconazole at 5 mg/kg by oral suspension. The suspension contains 100 mg/5 mL oral solution. What volume does the dog require per dose?
-
An owner arrives to collect her dog's prescription for ampicillin tablets. The dog weighs 23 kg and the dose of ampicillin suggested by the vet is 15 mg/kg/t.i.d. You have the tablets available in...
-
A 120-room building has 14 1-bedroom units renting monthly at $150.00. 12 2-bedroom units at $200.00, and 8 3-bedroom units at $250.00. The gross annual rental would be?
-
A company is planning to manufacture snowboards. The fixed costs are $129 per day and the total costs are $5,897 per daily output of 18 boards. What is the average costs per board tend to as...
-
Maya purchased a boat for $18,340. Its value depreciated by 15% in the first year she owned it. What was her boat worth at the end of this first year?
-
Discuss factors that contribute to the widespread, persistent gender pay gap in the United States. YOUR RESPONSE SHOULD BE AT LEAST 150 WORDS LONG AND DEMONSTRATE (Ctrl)
-
Graph one period of each function. y = 4 cos x
-
Modify the Bouncing Ball example from Listing 9.18, except instead of animating a red circle, animate an image of your choice. Listing 9.18 import javafx.application.Application; import...
-
Do Programming Project 17 from Chapter 4, the Edoc calculator, except use a recursive function to calculate or help you calculate the maximum amount of experience points you can earn. Project 17 from...
-
Write a program that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a...
-
True or False: Engineers seldom have an opportunity to influence the recovery period for expenditures.
-
A lumber company purchases and installs a wood chipper for \(\$ 200,000\). The chipper is classified as MACRS 7-year property. Its useful life is 10 years. The estimated salvage value at the end of...
-
True or False: Straight-line depreciation is the most popular depreciation method used in financial reporting.
Study smarter with the SolutionInn App