Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CISC231 Foundations of Computing ll Assignment 3 (100 pts): Create a public class named Yourlastname_l'ourrstname_hw3.java. In this java file, add the following default classes below
CISC231 Foundations of Computing ll Assignment 3 (100 pts): Create a public class named Yourlastname_l'ourrstname_hw3.java. In this java file, add the following default classes below this class: (10 pts) Problem 1 (30 pts) Create a class named Employee. An employee should include five pieces of information as instance variables: name (type String), id (type String), salary (type double), vacation_days (type int), and has_taken_vacation (type boolean, initial=false) -name: String -id: String -salary: double -vacation_days: int -has_taken_vacation: boolean Where vacations_days represents the number of vacations days for this employee this year and has_taken_vacation represents whether this employee has taken a vacation this year and its initial value should be false for all employees. 1. Add the private instance variables listed above to the Employee class. (5 pts) 2. Add a constructor method. (2 pts) 3. Add a public get method for instance variables: name, id, salary, vacation_days, and has_taken_vacation. (5 pts) 4. Add a public set method for instance variables: name, id, and salary. (3 pts) 5. Add a public method named take_vacation(int vacation_time). (5 pts) Ifthis employee has taken a vacation this year, he/she cannot take a vacation again, display "This employee has taken a vacation this year.\" If this employee hasn't taken any vacations this year, display \"not enough vacation days left." if vacation_time is greater than vacation_days. If vacation_time is less than or equal to vacation_days, deduct vacation_time from vacation_days, set has_taken_vacation to true, and display the number of remaining vacation days. 6. Add a public method named compensate() to calculate and return the compensation for the remaining vacation days. Assume an employee will get 100 dollars for each unused vacation day. (5 NS) Problem 2 (35 pts) Create a class named SavingAccount. A saving account should include five pieces of information as instance variables: customer_name (type String), customer_id (type String), account_id (type String), balance (type double, initial=0.0), annual_interest_rate (type float, vip:3.5%, non-vip: 3.0%), and is_vip (type boolean, default=false) -customer_name: String customer_id: String -account_id: String Page) 1 -balance: double -annual_interest_rate: float -is_vip: boolean Where balance represents the current balance and the initial balance should be zero for all the saving accounts, annua|_interest_rate represents the annual interest rate, is_vip represents whether this account is a vip account or not. For non-vip accounts, their annual interest rate should be 3.0%. For vip accounts, their annual interest rate should be 3.5%. 1. Add the private instance variables listed above to the SavingAccount class. (5 pts) 2. Add a constructor method. (2 pts) 3. Add a public get method for instance variables: customer_name, customer_id, account_id, balance, annual_interest_rate, and is_vip. (5 pts) 4. Add a public set method for instance variables: customer_name, customer_id, and account_id. (3 pts) 5. Add a public method named deposit(double amount) to deposit the given amount of money. This amount should be added to balance. (5 pts) 6. Add a public method named gain_interests(int years) to calculate the amount of interests gained after the given years and then add interests to balance. (5 pts) 7. Add a public method named promote_vip() to promote this account to a vip account if the current balance is greater than or equal to 50,000. (5 pts) Problem 3 (25 pts) Create a class named BankCustomer. A bank customer should include four pieces of information as customer_id (type String), customer_id (type String), saving_accounts (type SavingAccount, an array of saving accounts from problem 2), and number_of_accounts (type int, initial=0) -customer_name: String customer_id: String -saving_accounts: SavingAccount number_of_accounts: int Where saving_accounts should be an array that can hold up to five saving accounts, and number_of_accounts represents the number of accounts that this bank customer owns. If this bank customer has owned five saving accounts, he/she cannot open another one. 1. Add the private instance variables listed above to the BankCustomer class. (4 pts) 2. Add a constructor method. (2 pts) 3. Add a public get method for instance variables: customer_name, customer_id, saving_accounts, and number_of_accounts. (4 pts) 4. Add a public set method for instance variables: customer_name and customer_id. (2 pts) 5. Add a public method named open_new_account(5avingAccount acc, double dep_amt) to open a new saving account for this customer and deposit the given amount, dep_amt, into this saving account. Ifthis bank customer has owned five saving accounts, he/she cannot open another one. Display \"cannot open a new account because you already have five accounts.\" (8 pts) Pagel 2 In the Yourlastname_Yourfirstname_hw3 class, add the main method in which 1. you create two SavingAccount objects. (5 pts) 2. you create two Employee objects. (5 pts) 3. you create two BankCustomer objects. (5 pts) Submit Yourlastname_Yourfirstname_hw3.java. Page | 3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started