Computer Science Homework Solutions
Problem
#119715

Java Applet

Your team has been hired as a Java programmer by Real Estates Solutions Inc. Your task is to write a Java applet for their web site that would enable customers to figure out their monthly mortgage payments.

The applet input will be the loan amount, annual percentage rate or APR, and the number of years to pay out the loan. The output will be: the monthly payment amount, the number of payments, the total paid including interest, and total interest paid.

The calculations were provided to you by a real estate agent:

p, loan amount or principal
n, number of payments = payments per year * number of years
i, interest per period = apr/payments per year = apr/12
r, monthly payment amount = principal * interest per period / (1-(1+(interest per period)/100)^(number of payments-1)^2)
Hint: In Java syntax the monthly payment calculation is:

r=((p*(i/100))/(1-(Math.pow((1+(i/100)),(n*(-1))))));
Details:

Please note that your program should accept three inputs:

The loan amount,
Annual percentage rate or APR, and
The number of years to pay out the loan
And calculate four outputs:

The monthly payment amount,
Number of payments,
The total paid including interest, and
Total interest paid

When coding your applet, remember the following:

Your applet needs to extend the Applet (or JApplet) class. Of course, you need to import the appropriate applet package(s).
Your applet needs to have declarations for the fields, labels, components, widgets, etc. that you use in the applet.
There are applet methods that are called automatically by browsers. Make sure you initialize (implement init()) your applet.
You need the code that does the calculation of the interest.
You need to handle the event of pressing the button.
Please create an HTML page that contains the applet tag. In addition to your mortgage calculator commented Java code, you need to provide the HTML page.


Here is an example given to me from a facilitator to create an applet:


--------------------------------------------------------------------------------

mport java.applet.*;
   import java.awt.*;
/**
* The HelloWorld class implements an applet that
* simply displays "Hello World!".
*/
public class HelloWorld extends Applet {
public void paint(Graphics g){
// Display "Hello World!"
g.drawString("Hello world!", 50, 25);
}
}

--------------------------------------------------------------------------------

Then you would compile the class and create an HTML page called Hello.htm (ignore the periods, they're there to make the HTML code viewable):


--------------------------------------------------------------------------------

<.HTML>
  <.HEAD>
  <.TITLE>A Simple Program<./TITLE>
  <./HEAD>
  <.BODY>

Here is the output of my program:

<.APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
  <./APPLET>
  <./BODY>
  <./HTML>

Solution
What is this?
By OTA - Overall OTA Rating
Yupei Xiong, PhD - 4.8/5
Purchase Cost Now
$2.19 CAD (was ~$35.91)
Included in Download
  • Plain text response
  • Attached file(s):
    • RESolutions.java
    • RESolutions2.java
    • Test.html
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Declarations in C - ****This is "C" Programming**** I selected "b" but I've always seem to get lost doing Boolean. Assuming the following declarations: int A=1, B=2, C=3, D=4; What is the value of the fol ...
  • Data Structures with C++ (STL) - Consider the class declaration class demoClass { public: // assign arguments as initial values for the data members demoClass(int a = 5, int b = 10); // function ...
  • Form - 3 additional question for OTA 101620 - Dear OTA 101620 Thank you for your response. For the second question,I would like to ask how to automatically assign a specific value to a label for a text box. ( automatically assigns a label that r ...
  • Examples of correct Variable declaration in C++ - Which of the following variable declarations are correct? If a variable declaration is not correct give the reason(s) and provide the correct variable declaration. n = 12; //Line 1 ...
  • Data structures C++ - The free newString() takes string objects strA and strB as arguments. For its action, newString() compares the string by using < and returns the concatenation of the arguments, with the lesser sring c ...
Browse