Question: undefined Part C - Programming (1 hours 30 minutes) Write a complete Java programs based on the instruction given below. Refer Figure I for class




undefined
Part C - Programming (1 hours 30 minutes) Write a complete Java programs based on the instruction given below. Refer Figure I for class diagram relationship. The output is in Figure 2. a) Write a class Endowment with the following methods: (1) Write constructor for class Endowment that initializes endType, endid and donate PerBill instance variables through parameter passing. () Write suitable code for the accessor methods (refer Figure 1). b) Write a class Staff with the following methods: (0) Write constructor for class Staff that initializes staffNum and name instance variables through parameter passing. (ii) Write suitable code for the getName() accessor method. Write a class Donate with the following methods: ) Write constructor for class Donate that initializes donated Endowment, Staff and bill instance variables through parameter passing. (ii) Write method calcAll() which able to return the total value of Endowment amount times (x) with billumber of donation (Donated). (iii) Write method toString() which creates a string of Donate information d) Write a class TestDonate that only has main() method with the following codes: (1) Create three (2) objects of class Endowment using the constructor with the specified information as shown in Table 1. (ii) Create three (2) objects of class Staff using the constructor with the specified information as shown in Table 2. (iii) Create a Vector or ArrayList object named Donate to store the created objects of class Donate with the specified information as shown in Table 3. (iv) Use the for loop to print the list of Donates using toString() method. The program should produce the output as shown in Figure 2. Table 1 Object Name Endowment Type Amount Endowment Id 23 24 endl end2 Alumni Faculty 100.00 50.00 Table 2 Object Name staffi staff2 Staff Id 789 654 Staff Name Karim Jamal Table 3 Donate Id 1 2 Staff staffi stafl2 Endowment endi end2 Bill# Donated 1 Donate Endowment -donateld:int -bil:int - end: Endowment - staff: Staff + Donate (int, int, Endowment, Saff) + calAllo: double + toString(): String - endType: String - endId:int - donatePerBill: double + Endowment(String, int, double) +getType(): String +getAmount:double Staff TestDonate +main(String[]):void - staffNum: int -name: String + Staf(String, int) +getName():String Figure 1: UML class diagram List of donates: Donate: 1 Staff: Karim Endowment: Alumni Bill: 1 Amount per bill: 100.0 Total Price: 100.0 Donate: 2 Staff: Jamal Endowment: Faculty Bill: 3 Amount per bill: 50.0 Total Price: 150.0 Figure 2 : Output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
