Need help programming mortagage calculator for 3 different loans 7 year, 15 year and 30 year. using java array I am a beginner with Java, This is what I have so far. Need to know if I am off the path,
import java.math.*;//*loan calculator
import java.text.*;//*formats numbers
public class 3 Mortgage loans {
// declare class variable array
int[] mortgage calculator
//construct the array
mortgage calculator = new int[17]; -
-
-
Expand|Select|Wrap|Line Numbers
-
-
-
-
-
-
- double loan = 200000
-
-
double term1 =360//*360 month for 30 year mortgage
-
-
double interRate1 = 0.0575; //*5.75% 5.75/100interest rate 30year mortgage
-
-
double monthlyRate1 = (interestRate1/12)
-
-
double term2 = 84//*7year mortgage loan
-
-
double interestRate2 = 0.0535;//*5.35 5.35/100 interest rate 7 year mortgage
-
-
double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan
-
-
double term3 = 180
-
-
-
-
-
-
-
// 15 year mortgage
-
double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage
-
double monthlyRate3 = (interestRate3/12);//* monthlyRate for 15 year mortgage
-
-
//Discount factr calculator for the three loans
-
double discountFactor1 = (Math.pow ((1 + monthlyRate1),
-
term1)-1/(monthlyRate1 * Math.pow((1 + monthlyRate1),term1));
-
-
double discountFactor2 = (Math.pow((1 + monthlyRate2),term2)-1/
-
(monthlyRate2* Math.pow((1 + monthlyRate2),term2));
-
-
double discountFactor3 = (Math.pow((1 + monthlyRate3), term3) - 1)/
-
(monthlyRate3 * Math.pow((1 + monthlyRate3), term3));
-
-
double payment1 = loan/discountFactor1; //*Rate Calcualtion for 30 yearn mortgage
-
double payment2 = loan/discountFactor2; //*Rate Calculaion for 7 year morgage
-
double payment3 = loan/discountFactor3; //*Rate Clculation for 15 year mortgage
-
2 7864
Need help programming mortagage calculator for 3 different loans 7 year, 15 year and 30 year. using java array I am a beginner with Java, This is what I have so far. Need to know if I am off the path,
import java.math.*;//*loan calculator
import java.text.*;//*formats numbers
public class 3 Mortgage loans {
// declare class variable array
int[] mortgage calculator
//construct the array
mortgage calculator = new int[17]; -
-
-
Expand|Select|Wrap|Line Numbers
-
-
-
-
-
-
- double loan = 200000
-
-
double term1 =360//*360 month for 30 year mortgage
-
-
double interRate1 = 0.0575; //*5.75% 5.75/100interest rate 30year mortgage
-
-
double monthlyRate1 = (interestRate1/12)
-
-
double term2 = 84//*7year mortgage loan
-
-
double interestRate2 = 0.0535;//*5.35 5.35/100 interest rate 7 year mortgage
-
-
double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan
-
-
double term3 = 180
-
-
-
-
-
-
-
// 15 year mortgage
-
double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage
-
double monthlyRate3 = (interestRate3/12);//* monthlyRate for 15 year mortgage
-
-
//Discount factr calculator for the three loans
-
double discountFactor1 = (Math.pow ((1 + monthlyRate1),
-
term1)-1/(monthlyRate1 * Math.pow((1 + monthlyRate1),term1));
-
-
double discountFactor2 = (Math.pow((1 + monthlyRate2),term2)-1/
-
(monthlyRate2* Math.pow((1 + monthlyRate2),term2));
-
-
double discountFactor3 = (Math.pow((1 + monthlyRate3), term3) - 1)/
-
(monthlyRate3 * Math.pow((1 + monthlyRate3), term3));
-
-
double payment1 = loan/discountFactor1; //*Rate Calcualtion for 30 yearn mortgage
-
double payment2 = loan/discountFactor2; //*Rate Calculaion for 7 year morgage
-
double payment3 = loan/discountFactor3; //*Rate Clculation for 15 year mortgage
-
use public class MortgageLoans as the class name. The one you have is invalid.
You should define 3 arrays of type double not one of type int
You will also need a loop to calculate the monthly repayments amounts.
Make the above corrections and post the code
Unfortunately. This maybe a second posting. I sorry just getting started with this chat area. See new code below:
/**
* @(#)3 Mortgage loans.java
*
* 3 Mortgage loans application
*
* Phyllis J Jones
* Purpose to write a program in Java without a graphical user interface and have
it calculate the payment amount for 3 mortgage loans.
*/
import java.math.*;//*loan calculator
import java.text.*;//*formats numbers
public class MortgageLoans {
// declare class variable array
double mortgage calculator1[];
double mortgage calculator2[];
double mortgage calculator3[];
//construct the array
mortgage calculator1 = new double[6];
mortgage calculator2 = new double[6];
mortgage calculator3 = new double[6];
double loan = 200000
double term1 =360//*360 month for 30 year mortgage
double interRate1 = 0.0575; //*5.75% 5.75/100interest rate 30year mortgage
double monthlyRate1 = (interestRate1/12)
double term2 = 84//*7year mortgage loan
double interestRate2 = 0.0535;//*5.35 5.35/100 interest rate 7 year mortgage
double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan
double term3 = 180 // 15 year mortgage
double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage
double monthlyRate3 = (interestRate3/12);//* monthlyRate for 15 year mortgage
//Discount factr calculator for the three loans
double discountFactor1 = (Math.pow ((1 + monthlyRate1),
term1)-1/(monthlyRate1 * Math.pow((1 + monthlyRate1),t erm1));
double discountFactor2 = (Math.pow((1 + monthlyRate2),t erm2)-1/
(monthlyRate2* Math.pow((1 + monthlyRate2),t erm2));
double discountFactor3 = (Math.pow((1 + monthlyRate3), term3) - 1)/
(monthlyRate3 * Math.pow((1 + monthlyRate3), term3));
double payment1 = loan/discountFactor1 ; //*Rate Calcualtion for 30 yearn mortgage
double payment2 = loan/discountFactor2 ; //*Rate Calculaion for 7 year morgage
double payment3 = loan/discountFactor3 ; //*Rate Clculation for 15 year mortgage
//loop While not done
while(loan > 0)
{
java.text.Decim alFormat dfm = new java.text.Decim alFormat(",###. 00");
System.out.prin tln("Your monthly payment is $" + dfm.format(paym ent)+ "cemts");
// loop while done
if(loan>0)
{
double payment1 = loan/discountFactor1 ;//*Rate Calculation
double payment2 = loan/discountFactor2 ;//*Rate Calculation
double payment3 = loan/duiscountFactor 3;//*Rate Calculation
}
else
payment1 = payment/discountFactor1 ;//Rate Calculation
payment2 = payment/discountFactor2 ;//Rate Calcuklation
payment3 = payment/discountfactor3 ;//Rate Calculation
}
//Output
}
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Rvenkatesh |
last post by:
How to use array string in C#.Net to compare and replace
characters between strings using function.
|
by: Matt |
last post by:
I'm new to Java but experienced with PL/SQL. I've found what appears to be
strange behaviour (a bug?) when attempting to create java stored objects
using the UNIX version of Oracle SQL*PLUS 8.1.7.3.0 with JServer 8.1.7.3.0.
The reason it seams strange is that the problem only occurs with the UNIX
version of SQL*PLUS, not the PC client version running on Windows 2000 but
connected to the same database and schema. Can anyone shed any light...
|
by: Sebastian Fey |
last post by:
hi,
im looking for a way to paramterize a xml document.
ive a documentation in docbook-xml and want to transform it using two
different sets of entities.
(resulting documents just differ in some productcodes and names)
i think this could be done using xml-catalogs (right?) but unforunately im
using IE for a quick preview and it cant handle catalogs.
|
by: nel |
last post by:
hi..
i want to know how to insert data using array in mysql where the data stored in field given? this field_name i taken from database....
thanks a lot...
|
by: palani12kumar |
last post by:
Hi
i've implemented a linear Queue using array.
But i've been struck up with a doubt!!!!!
Let me tell my problem with an example so that it can be clear.
Size of the Queue(array) is 5.
im initializing the front and rear to 0.
I continously add five elements to the Queue, so that now the rear points to the 4th position of the array and now the queue is full.
Now i delete all the five elements and now the Front and the Rear points at...
| |
by: aliag |
last post by:
HI
I am trying to clal a java webservice (JWS) using java script but i keep on getting a "undefined" value
calling a .NET webservices works fine using the webservice.htc file but i cant get the same result with the java web service
I would really appreciate your help on this
|
by: shoonya |
last post by:
i am using array as a data type in my db
....
(
sequence integer
) ;
and it stores a value
let {1,2,3,4,5}
|
by: berrylthird |
last post by:
This question was inspired by scripting languages such as JavaScript. In JavaScript, I can access members of a class using array syntax as in the following example:
var myInstance:myClass = new myClass();
myInstance.member_0 = memberValue_0; // absolute notation
myInstance = memberValue_0; // relative notation
myInstance = memberValue_0; // nominal notation
You can initialize a struct in C/C++ like you would an array, as with the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |