Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java please. I'm looking for examples to compare against mine to see where my methods and math aren't working quite right. use the customer

In Java please. I'm looking for examples to compare against mine to see where my methods and math aren't working quite right.

use the customer name, loan amount, interest rate, number of monthly payments, and down payment to create an AutoLoan object and store the object in the arrayList (Java) / List (C#) - Create a method deleteLoan, which returns no values and takes in one (1) parameter, an arrayList (Java) / List (C#) of Loan objects: prompt the user to enter and read in a customer name search the arrayList (Java) / List (C#) for the object containing the user provided customer name if the object is fo prompt the user to enter and read in the amount of down payment use the customer name, loan amount, interest rate, number of monthly payments, and deferment to create a StudentLoan object and store the object in the arrayList (Java) / List (C#) if the loan type is Auto: prompt the user to enter and read in whether the loan is deferred (true or false) Your task: For this assignment, you will implement the Loan, StudentLoan and AutoLoan classes, utilizing the fundamentals of inheritance, polymorphism, and ArrayLists (Java) / Lists (C#). Define the following three classes: 1) Loan Class a) Must have the following attributes: - customerName, string, private, employees full name - accountNumber, int, private, unique account number - loanBalance, double, private, balance of customer loan - monthlyPayment, double, private, amount of each monthly payment - interestRate, double, private, amount of interest rate - numberOfMonthlyPayments, int, private, number of monthly loan payments - numberOfLoans, int, static, private, unique identifier used as account number, initialized with zero (0) (incremented by one each time an object is created) b) Must have an overloaded constructor which: - takes in a parameter, name, of type string, and assigns it to the customerName attribute - takes in a parameter, amount, of type double, and assigns it to the loanBalance attribute - takes in a parameter, rate, of type double, and assigns it to the interestRate attribute - takes in a parameter, months, of type int, and assigns it to the numberOfMonthlyPayments attribute - assigns the value of ++numberOfLoans to the accountNumber attribute (i.e. the creation of each object increments the numberOfLoans attribute, which is assigned to the accountNumber attribute) c) Must have a static method called getNumberOfLoans, which returns the value of the static attribute numberOfLoans d) Must have getter/setter methods for all attributes (no setter method needed for numberOfLoans attribute) e) Must have a static method called decreaseNumberOfLoans, which returns no value, takes in no parameters, and decrements the static attribute numberOfLoans by one (1) (i.e. numberOfLoans--) f) Must have a method called calculateMonthlyPayment, which returns no value, takes in no parameters, calculates the amount of monthly payment, and stores it in the monthlyPayment attribute, using the following formula: P = monthly payment PV = amount of loan r = interest rate n = number of payments (hint: consider using the Math class method Power for exponents) g) Must override the tostring method to return a string which includes a label and value for all attributes (i.e. Customer Name, Account Number, Loan Balance, Monthly Payment, Interest Rate, Number of Monthly Payments) 2) StudentLoan Class a) Must inherit Loan Class b) Must have the following attribute: - isDeferred, boolean, private, Indicates whether the loan is in deferment (true or false) c) Must have an overloaded constructor which: - takes in a parameter, name, of type string - takes in a parameter, amount, of type double - takes in a parameter, rate, of type double - takes in a parameter, months, of type int - takes in a parameter, isDef, of type boolean, and assigns it to isDeferred - call parent (base/super) constructor, passing the following values: name, amount, rate, months d) Must have getter/setter methods for the isDeferred attribute e) Must override the method calculateMonthlyPayment, which returns no value, takes in no parameters, calculates the amount of monthly payment, and stores it in the monthlyPayment attribute, using the following: If the loan is in deferment, the amount of monthly payment is zero (0). If the loan is not in deferment, the amount of the monthly payment is calculated as follows: P = monthly payment PV = amount of loan r = interest rate n = number of payments (hint: consider using the Math class method Power for exponents) f) Must override the tostring method to return a string which includes a label and value for all attributes (i.e. Customer Name, Account Number, Loan Balance, Monthly Payment, Interest Rate, Number of Monthly Payments, and Is Deferred) Note: most of this is in the parent (base/super) toString. 3) AutoLoan Class a) Must inherit Loan Class b) Must have the following attribute: - downPayment, double, private, Amount of down payment c) Must have an overloaded constructor which: - takes in a parameter, name, of type string - takes in a parameter, amount, of type double - takes in a parameter, rate, of type double - takes in a parameter, months, of type int - takes in a parameter, down, of type double, and assigns it to the downPayment attribute - call parent (base/super) constructor passing the following values: name, amount, rate, months d) Must have getter/setter methods for the downPayment attribute e) Must override the method calculateMonthlyPayment, which returns no value, takes in no parameters, calculates the amount of monthly payment, and stores it in the monthlyPayment attribute, using the following: P = monthly payment PV = (amount of loan) (down payment) r = interest rate n = number of payments (hint: consider using the Math class method Power for exponents) f) Must override the tostring method to return a string which includes a label and value for all attributes (i.e. Customer Name, Account Number, Loan Balance, Monthly Payment, Interest Rate, Number of Monthly Payments, and Down Payment) Note: most of this is in the parent (base/super) toString. Driver Program: In the driver class: - Create an ArrayList (Java) / List (C#) of Loan objects. - Create a method addLoan, which returns no values and takes in one (1) parameter, an arrayList (Java) / List (C#) of Loan objects: prompt the user to enter and read in a loan type (Student or Auto) prompt the user to enter and read in a customer name prompt the user to enter and read in a loan amount prompt the user to enter and read in a loan interest rate prompt the user to enter and read in the number of monthly payments if the loan type is Student: und, remove the object from the arrayList (Java) / List (C#), update the numberOfLoans attribute, and end the search - Create a method calculateMonthlyLoanPayment, which returns no values and takes in one (1) parameter, an arrayList (Java) / List (C#) of Loan objects: Traverse the entire arrayList (Java) / List (C#) For each object in the arrayList (Java) / List (C#), invoke the calculateMonthlyPayment method to compute the amount of the monthly payment. - Create a method printLoans, which returns no values and takes in one (1) parameter, an arrayList (Java) / List (C#) of Loan objects: Traverse the entire arrayList (Java) / List (C#) For each object in the arrayList (Java) / List (C#), print the object - Using a loop, prompt the user with the following menu and read in the users response: 1 Add Loan 2 Delete Loan 3 Calculate Monthly Payments 4 Print Loans 5 Exit Enter Choice: If the user enters 1, invoke the method addLoan If the user enters 2, invoke the method deleteLoan If the user enters 3, invoke the method calculateMonthlyLoanPayment If the user enters 4, invoke the method printLoans If the user enters 5, terminate the program If the user enters any character other than a 1, 2, 3, 4, or 5, the following error message should display: Error: Please enter valid input, and the user should be allowed to reenter a valid choice. Hint: In Java, you may want to make Scanner a static object in the main class (i.e. static Scanner input = new Scanner(System.in)). This allows you to read in input from the console from inside you user-defined methods.

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

Step: 3

blur-text-image

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

The Core Ios Developer S Cookbook Core Recipes For Programmers

Authors: Erica Sadun ,Rich Wardwell

5th Edition

0321948106, 978-0321948106

More Books

Students also viewed these Programming questions