Ask Experts Questions for FREE Help !
Ask
    o21vais's Avatar
    o21vais Posts: 1, Reputation: 1
    New Member
     
    #1

    Oct 9, 2013, 05:25 PM
    Java program help!!
    Dr.Java method and overloaded methods help in code?

    Write a program that uses two overloaded methods to calculate the monthly payment for a loan. The formula for calculating a payment is shown further down.

    Given that the user enters:
    - an annual interest rate such as 3.600%, which is the decimal value 0.036
    - the number of years over which the loan will be repaid such as 5.
    - a loan amount such as 10000 dollars

    Convert the annual values for the interest and years to monthly values:
    - the monthly interest rate, which we'll abbreviate as mir, is 0.036/12 or 0.003.
    - the number of months over which the loan will be repaid, which we'll abbreviate as mtp (months to pay), is 5 * 12 or 60.

    Annuity factor = mir/(1-(1/(1+mir))^mtp)

    In this example, the results of substituting the values in the formula are:

    Annuity factor = 0.003/(1-(1/(1+0.003))^60)
    Annuity factor = 0.018237

    Payment = Amount Loaned * Annuity Factor
    Payment = 10000*0.018237
    Payment = 182.37

    You must use the pow method in the Math class. This makes writing the annuity factor formula more awkward. It's easier if you break it down into some extra steps:

    1. Intermediate interest rate = Math.pow((1+0.003), 60)
    2. Annuity factor = 0.003 / (1-(1/Intermediate interest rate))

    Here's where the overloading comes in: some applications will define the amount as an int(integer), and other will define it as a double. Therefore, you need to write two overloaded versions of this method:

    1) one that takes the annual interest rate as a double, the number of years as an int and the amount loaned as an int(integer).

    2) another one that takes the annual interest rate as an double, the number of years as an int(integer) and the amount loaned as a double.

    Your main method will obtain input from the user who will provide an annual interest rate and the number of years over which the loan will be repaid. The payment calculating method will convert them to monthly values.

    Get user input only once and use cast operators to either convert int(integer ) value to double or double values to int(integer) before invoking a method.

    Use the data given in the example above to validate that methods correctly calculate loan payments.

    Use JOptionPane to obtain input from the user.

    ****** Please help me with this code this is my second time am using java program and I don't have much experience in this. Thanks.
    Additional Details
    I having hard time to begin with this program. HOw should I start and how can I use overloaded method.
    ma0641's Avatar
    ma0641 Posts: 15,675, Reputation: 1012
    Uber Member
     
    #2

    Oct 9, 2013, 06:21 PM
    Surely you don't expect us to do this for you. Your instructor should help you. If you don't learn, what happens the third time?

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Java netbeans program- Connection between java and mysql,How to conn [ 0 Answers ]

which I wrote from a book but when I run it, it shows exception please give me the code to connect jlistbox to database when I click on btn1. btn coding should search "name" in database and shows all the names in listbox my coding: here-- r1,r2,r3 are radio btns and l1,l2,l3 are labels,...

Java Program- Help Needed [ 0 Answers ]

How do I write this code? You will ask the user for 2 inputs, the total number of chocolate, and the amount of chocolate that goes into the making of the large bar. You must be able to accept decimal point values for both. The small bar value is fixed at 0.5. To solve this program, we want you...

Java Program [ 2 Answers ]

1) Code a java class for an Object SONG, that has as a minimum the following attributes:- SONG Title (a String) , SONG Group/artist (a String ), SONG genre (a String – “Pop”, “Jazz”, “Hard Rock” etc. SONG price (double), SONG duration (int number of seconds). Code all accessor and mutator methods...

Postfix program in java [ 0 Answers ]

Java program? [ 2 Answers ]

we have an assignment! but hold up! I would only ask what is the name of this code if I have fill up the blanks! code: puclic class problim{ public static void main(Stringarg){ int x=___; int y=___; while;(__<s){ x=____;


View more questions Search