Question

In: Computer Science

Hello, I am just having a hard time understanding this question. The question is below. I...

Hello, I am just having a hard time understanding this question. The question is below. I am not supposed to write a program but instead in regular english sentence form just name the methods, fields, and variables I would use for this loan class. Im not really sure what a loan class means as well, thank you for your help.

USING JAVA Given a Loan class, name the necessary fields and methods that we would need in this class. Be creative in your naming of variables and methods.

Solutions

Expert Solution

/**************************************
*            Loan                     *
*-----------------------------------  *
* -annualInterestRate: double         *
* -numberOfYears: int                 *
* -loanAmount: double                 *
* -loanDate: java.util.Date           *
* +Loan()                             *
* +Loan(annualInterestRate: double,   *
*   numberOfYears: int,loanAmount:    *
*   double)                           *
* +getAnnualInterestRate(): double    *
* +getNumberOfYears(): int            *
* +getLoanAmount(): double            *
* +getLoanDate(): java.util.Date      *
* +setAnnualInterestRate(             *
*   annualInterestRate: double): void *
* +setNumberOfYears(                  *
*   numberOfYears: int): void         *
* +setLoanAmount(                     *
* loanAmount: double): void           *
* +getMonthlyPayment(): double        *
* +getTotalPayment(): double          *
**************************************/

// Implement Serializable
public class Loan implements java.io.Serializable {
        private double annualInterestRate;
        private int numberOfYears;
        private double loanAmount;
        private java.util.Date loanDate;

        /** Default constructor */
        public Loan() {
                this(2.5, 1, 1000);
        }

        /** Construct a loan with specified annual interest rate, 
            number of years, and loan amount
         */
        public Loan(double annualInterestRate, int numberOfYears,
                double loanAmount) {
                this.annualInterestRate = annualInterestRate;
                this.numberOfYears = numberOfYears;
                this.loanAmount = loanAmount;
                loanDate = new java.util.Date();
        }

        /** Return annualInterestRate */
        public double getAnnualInterestRate() {
                return annualInterestRate;
        }

        /** Set an new annualInterestRate */
        public void setAnnualInterestRate(double annualInterestRate) {
                this.annualInterestRate = annualInterestRate;
        }

        /** Return numberOfYears */
        public int getNumberOfYears() {
                return numberOfYears;
        }

        /** Set a new numberOfYears */
        public void setNumberOfYears(int numberOfYears) {
                this.numberOfYears = numberOfYears;
        }

        /** Return loanAmount */
        public double getLoanAmount() {
                return loanAmount;
        }

        /** Set a new loanAmount */
        public void setLoanAmount(double loanAmount) {
                this.loanAmount = loanAmount;
        } 

        /** Find monthly payment */
        public double getMonthlyPayment() {
                double monthlyInterestRate = annualInterestRate / 1200;
                double monthlyPayment = loanAmount * monthlyInterestRate / (1 -
                        (1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)));
                return monthlyPayment;
        }

        /** Find total payment */
        public double getTotalPayment() {
                double totalPayment = getMonthlyPayment() * numberOfYears * 12;
                return totalPayment;
        }
        
        /** Return loan date */
        public java.util.Date getLoanDate() {
                return loanDate;
        }

        @Override /** Override the toString method in the Object class */
        public String toString() {
                return "Date: " + loanDate + "\nAnnual interest Rate: " + 
                        annualInterestRate + "\nYears: " + numberOfYears +
                        "\nLoan amount: " + loanAmount;
        }
}

Note, if you like the answer, please consider upvoting. ;-)


Related Solutions

I understand the answer to this I am just having a hard time creating a graph...
I understand the answer to this I am just having a hard time creating a graph for it. Bill the butcher is upset because the government plans to tax beef $.10 a pound. "I hate paying taxes," he says. "Because of this, I'm raising all my beef prices by $.10 a pound. The consumers will bear this burden, not me." Do you see anything wrong with this way of thinking? Explain. Draw a graph describing your answer and attach it...
can someone explain to me what osmolality is.? i am having a hard time understanding it
can someone explain to me what osmolality is.? i am having a hard time understanding it
I am having a hard time understanding these two questions. If someone can explain that would...
I am having a hard time understanding these two questions. If someone can explain that would be great. 1) Explain the steps that enables body to metabolize fat to ATP? 2) Write out the amount of ATP, NADH, FADH2 produced in each step of cellular metabolism of a glucose.
Hello, I am having a hard time being able to fully understand how firm strategy, technology...
Hello, I am having a hard time being able to fully understand how firm strategy, technology and investment affects the emergence of the digital gaming industry? Please go into great detail.
C# programming. Comment/Explain the below code line by line. I am having a hard time following...
C# programming. Comment/Explain the below code line by line. I am having a hard time following it. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Nth_prime {     class Program     {         public static bool isPrime(int number)         {             int counter = 0;             for (int j = 2; j < number; j++)             {                 if (number % j == 0)                 {                     counter = 1;                     break;                 }             }             if (counter == 0)             {                 return true;             }             else             {                 return false;             }         }...
hello, I am having an issue with a question in my highway engineering course. the question...
hello, I am having an issue with a question in my highway engineering course. the question is: An equal tangent sag vertical curve has an initial grade of –2.5%. It is known that the final grade is positive and that the low point is at elevation 82 m and station 1 + 410.000. The PVT of the curve is at elevation 83.5 m and the design speed of the curve is 60 km/h. Determine the station and elevation of the...
I am having a hard time getting started on how to do this assignment. I would...
I am having a hard time getting started on how to do this assignment. I would like some ideas on how to start the MEMO. and maybe some ideas on what you would include. But I don't necessarily need the assignment completed for me. just need ideas!!! One routine negative message in the form of an internal memo. 400-500 word message. Single-spaced, with 1-inch margins on all sides. Objective: To announce organizational restructuring, one routine negative message addressed to employees....
I have figured out this assignment, but I am having a hard time figuring out the...
I have figured out this assignment, but I am having a hard time figuring out the extra credit, Thanks! Creating a Rectangle class We have created a representation of a rectangle in C++ and extended it to create multiple representation's of rectangles. Classes can simplify that process considerably. In this assignment, your task is to convert the representation of a rectangle we created earlier in the semester to a Rectangle class. The Rectangle class shall consist of the following: The...
Hello, I'm having a hard time solving these problems because I have no idea on what...
Hello, I'm having a hard time solving these problems because I have no idea on what to do with accrued interest. Help is highly appreciated! On March 1, 2015, Bowan Corporation issued 6% bonds dated February 1, 2015, the face amount of $700,000. The bonds were sold for the present value of the bonds on March 1, 2015 plus one-month accrued interest. The bonds mature on January 31, 2018. Interest is paid semiannually on July 31 and January 31. Bowan's...
Below is the assignment that I need to do and having a hard time finding the...
Below is the assignment that I need to do and having a hard time finding the correct ratios like Gross Margin, EBITD, Price to cash flow etc.. from SEC EDGAR. I am comparing CVS Health and Walgreens 2018. Below is the question similar to mine that I found on the website. I am trying to figure out where can I find those ratios? MBA 520 Module Two Activity Guidelines and Rubric Overview: For this task, you will analyze the financial...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT