473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

I need help

Yes this is a homework assignment. My instructor has broken english and I
just could not follow along last night. How do I do this

Write the program in Java (without a graphical user interface) and have it
calculate the payment amount for 3 mortgage loans:

a.. 7 year at 5.35%
b.. 15 year at 5.5%
c.. 30 year at 5.75%
Use an array for the different loans. Display the mortgage payment amount
for each loan.
My first one is below that works but how do I do the above

public class wtest
{

public static void main (String[] args)
{
double principal =2000000.0;
double rate =5.75;
double term =30.0;
double monthlyPayment =0.0;

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}
--
The best live web video on the internet http://www.seedsv.com/webdemo.htm
NEW Embedded system W/Linux. We now sell DVR cards.
See it all at http://www.seedsv.com/products.htm
Sharpvision simply the best http://www.seedsv.com


Feb 23 '06 #1
10 6255


(Was it really necessary to post this question to four
count them four different newsgroups, at least one of which
has nothing to do with Java? Methinks a brief look at some
of the "new to Usenet" or "Emily Postnews" articles would
be of benefit ...)
pcbutts1 wrote On 02/23/06 14:33,:
Yes this is a homework assignment. My instructor has broken english and I
just could not follow along last night. How do I do this

Write the program in Java (without a graphical user interface) and have it
calculate the payment amount for 3 mortgage loans:

a.. 7 year at 5.35%
b.. 15 year at 5.5%
c.. 30 year at 5.75%
Use an array for the different loans. Display the mortgage payment amount
for each loan.
My first one is below that works but how do I do the above

public class wtest
{

public static void main (String[] args)
{
double principal =2000000.0;
double rate =5.75;
double term =30.0;
double monthlyPayment =0.0;

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}


Since it's homework, I'll give a hint rather than
an all-out answer:

public class Wtest {
public static void main (String[] args) {
double principal = 2000000.0; // nice house!
double[] rates = { 5.35, 5.5, 5.75 };
double[] terms = { 7.0, 15.0, 30.0 };
for (int i = 0; i < rates.length; ++i) {
...

I hope this helps!

--
Er*********@sun.com

Feb 23 '06 #2
Thanks for the tip. Sorry for the cross post, I wanted the maximum results
by reading only one group. I snipped the java script group. Thanks again.

--
The best live web video on the internet http://www.seedsv.com/webdemo.htm
NEW Embedded system W/Linux. We now sell DVR cards.
See it all at http://www.seedsv.com/products.htm
Sharpvision simply the best http://www.seedsv.com

"Eric Sosman" <Er*********@sun.com> wrote in message
news:dt**********@news1brm.Central.Sun.COM...


(Was it really necessary to post this question to four
count them four different newsgroups, at least one of which
has nothing to do with Java? Methinks a brief look at some
of the "new to Usenet" or "Emily Postnews" articles would
be of benefit ...)
pcbutts1 wrote On 02/23/06 14:33,:
Yes this is a homework assignment. My instructor has broken english and I
just could not follow along last night. How do I do this

Write the program in Java (without a graphical user interface) and have
it
calculate the payment amount for 3 mortgage loans:

a.. 7 year at 5.35%
b.. 15 year at 5.5%
c.. 30 year at 5.75%
Use an array for the different loans. Display the mortgage payment amount
for each loan.
My first one is below that works but how do I do the above

public class wtest
{

public static void main (String[] args)
{
double principal =2000000.0;
double rate =5.75;
double term =30.0;
double monthlyPayment =0.0;

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}


Since it's homework, I'll give a hint rather than
an all-out answer:

public class Wtest {
public static void main (String[] args) {
double principal = 2000000.0; // nice house!
double[] rates = { 5.35, 5.5, 5.75 };
double[] terms = { 7.0, 15.0, 30.0 };
for (int i = 0; i < rates.length; ++i) {
...

I hope this helps!

--
Er*********@sun.com

Feb 23 '06 #3
Can you give me another hint? I am still lost.

--
The best live web video on the internet http://www.seedsv.com/webdemo.htm
NEW Embedded system W/Linux. We now sell DVR cards.
See it all at http://www.seedsv.com/products.htm
Sharpvision simply the best http://www.seedsv.com

"Eric Sosman" <Er*********@sun.com> wrote in message
news:dt**********@news1brm.Central.Sun.COM...


(Was it really necessary to post this question to four
count them four different newsgroups, at least one of which
has nothing to do with Java? Methinks a brief look at some
of the "new to Usenet" or "Emily Postnews" articles would
be of benefit ...)
pcbutts1 wrote On 02/23/06 14:33,:
Yes this is a homework assignment. My instructor has broken english and I
just could not follow along last night. How do I do this

Write the program in Java (without a graphical user interface) and have
it
calculate the payment amount for 3 mortgage loans:

a.. 7 year at 5.35%
b.. 15 year at 5.5%
c.. 30 year at 5.75%
Use an array for the different loans. Display the mortgage payment amount
for each loan.
My first one is below that works but how do I do the above

public class wtest
{

public static void main (String[] args)
{
double principal =2000000.0;
double rate =5.75;
double term =30.0;
double monthlyPayment =0.0;

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}


Since it's homework, I'll give a hint rather than
an all-out answer:

public class Wtest {
public static void main (String[] args) {
double principal = 2000000.0; // nice house!
double[] rates = { 5.35, 5.5, 5.75 };
double[] terms = { 7.0, 15.0, 30.0 };
for (int i = 0; i < rates.length; ++i) {
...

I hope this helps!

--
Er*********@sun.com

Feb 25 '06 #4
I got the errors down to 7 from 12 when trying to compile. Can someone
explain these error and how to fix them.

C:\w1>javac Wtest.java
Wtest.java:10: operator / cannot be applied to double[],double
rate = rate/1200.0;
^
Wtest.java:11: operator * cannot be applied to double[],int
term = term * 12;
^
Wtest.java:12: cannot resolve symbol
symbol : variable monthlyPayment
location: class Wtest
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
^
Wtest.java:12: operator * cannot be applied to double,double[]
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
^
Wtest.java:12: operator + cannot be applied to double[],int
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
^
Wtest.java:12: operator - cannot be applied to double[]
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
^
Wtest.java:13: cannot resolve symbol
symbol : variable monthlyPayment
location: class Wtest
System.out.println(monthlyPayment);
^
This is the file

public class Wtest
{
public static void main (String[] args)
{
double principal = 2000000.0; // nice house!
double[] rate = { 5.35, 5.5, 5.75 };
double[] term = { 7.0, 15.0, 30.0 };
for (int i = 0; i < rate.length; ++i)

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}

--
The best live web video on the internet http://www.seedsv.com/webdemo.htm
NEW Embedded system W/Linux. We now sell DVR cards.
See it all at http://www.seedsv.com/products.htm
Sharpvision simply the best http://www.seedsv.com

"Eric Sosman" <Er*********@sun.com> wrote in message
news:dt**********@news1brm.Central.Sun.COM...


(Was it really necessary to post this question to four
count them four different newsgroups, at least one of which
has nothing to do with Java? Methinks a brief look at some
of the "new to Usenet" or "Emily Postnews" articles would
be of benefit ...)
pcbutts1 wrote On 02/23/06 14:33,:
Yes this is a homework assignment. My instructor has broken english and I
just could not follow along last night. How do I do this

Write the program in Java (without a graphical user interface) and have
it
calculate the payment amount for 3 mortgage loans:

a.. 7 year at 5.35%
b.. 15 year at 5.5%
c.. 30 year at 5.75%
Use an array for the different loans. Display the mortgage payment amount
for each loan.
My first one is below that works but how do I do the above

public class wtest
{

public static void main (String[] args)
{
double principal =2000000.0;
double rate =5.75;
double term =30.0;
double monthlyPayment =0.0;

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}


Since it's homework, I'll give a hint rather than
an all-out answer:

public class Wtest {
public static void main (String[] args) {
double principal = 2000000.0; // nice house!
double[] rates = { 5.35, 5.5, 5.75 };
double[] terms = { 7.0, 15.0, 30.0 };
for (int i = 0; i < rates.length; ++i) {
...

I hope this helps!

--
Er*********@sun.com

Feb 25 '06 #5
pcbutts1 wrote:
I got the errors down to 7 from 12 when trying to compile. Can someone
explain these error and how to fix them. ....
public class Wtest
{
public static void main (String[] args)
{
double principal = 2000000.0; // nice house!
double[] rate = { 5.35, 5.5, 5.75 };
double[] term = { 7.0, 15.0, 30.0 };
for (int i = 0; i < rate.length; ++i)

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}


Ok pcbutts1. Since you mentioned DOS, I figure you are no spring chicken and
therefore not a spotty kid too lazy to do the work. Assuming your difficulty is
genuine, here is my way of tackling this problem (to which Eric Sosman has
given a partial solution + java syntax) -

thinking first
principal is 2,000,000
interest is 5.35% per annum
Therefore interest per year is 2000000 x .0535 = 107000
Total interest is 107000 x 7 = 749000
Therefore total to be repaid is 2000000 + 749000 = 2749000
number of months' repayment is 7 x 12 = 84
Thererefore monthly repayment is 32,726.20

answer = ((2000000 * 0.0535 * 7) + 2000000)/(7 * 12)
Now, do a sanity check on the answer (perhaps on a calculator). If it checks
out replace it with the correct java syntax

monthlyPayment = ((principal * (rate[i]/100) * term[i]) + principal) / (term[i]
* 12)

Other things - brush up on arrays, the for statement, indent the code correctly
and figure out when to use double or integers, how to get the correct display
to 2 decimal places.

I am too lazy to check your (1.0 - Math.pow(rate+1,-term)) for what it means.
The syntax is incorrect anyway but if the logic is correct, use it. Otherwise
do the code yourself.

--
Why is the alphabet in that order? Is it because of that song?
-- Steven Wright
Feb 25 '06 #6
"pcbutts1" <pc******@seedsv.com> wrote in
news:N9******************************@giganews.com :
I got the errors down to 7 from 12 when trying to compile. Can someone
explain these error and how to fix them.

C:\w1>javac Wtest.java
Wtest.java:10: operator / cannot be applied to double[],double
rate = rate/1200.0;

First note I did not examine your original post, so I don't know if what
I'm telling you is correct with regards to the logic you need. I am
only commenting on the compilation errors you listed.

rate is an array of doubles. You cannot divide an array by a double,
you instead need to divide each of the elements of the array. This is
done with a loop, for example:

for(int i = 0; i < rate.length; i++)
{
rate[i] = rate[i] / 1200.00
}

^
Wtest.java:11: operator * cannot be applied to double[],int
term = term * 12;
same as above
^
Wtest.java:12: cannot resolve symbol
symbol : variable monthlyPayment
location: class Wtest
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term)); ^
What is monthlyPayment? It has not been defined anywhere in the
program. In Java, you need to define all your variables (tell the
compiler what type they have) before using them. In many cases, you'll
also need to initialize (give them a specific value) before using them.
Wtest.java:12: operator * cannot be applied to double,double[]
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term));
^
Wtest.java:12: operator + cannot be applied to double[],int
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term));
^
Wtest.java:12: operator - cannot be applied to double[]
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term));
^
Wtest.java:13: cannot resolve symbol
symbol : variable monthlyPayment
location: class Wtest
System.out.println(monthlyPayment);
These are all the same errors as above


This is the file

public class Wtest
{
public static void main (String[] args)
{
double principal = 2000000.0; // nice house!
double[] rate = { 5.35, 5.5, 5.75 };
double[] term = { 7.0, 15.0, 30.0 };
for (int i = 0; i < rate.length; ++i)

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term)); System.out.println(monthlyPayment);
}

}


Feb 25 '06 #7
I'm sorry but I am still lost. I think it's because I just don't know the
commands or syntax or when or where to use them.

--
The best live web video on the internet http://www.seedsv.com/webdemo.htm
NEW Embedded system W/Linux. We now sell DVR cards.
See it all at http://www.seedsv.com/products.htm
Sharpvision simply the best http://www.seedsv.com

"ge0rge" <ge****@privacy.net> wrote in message
news:46************@individual.net...
pcbutts1 wrote:
I got the errors down to 7 from 12 when trying to compile. Can someone
explain these error and how to fix them.

...

public class Wtest
{
public static void main (String[] args)
{
double principal = 2000000.0; // nice house!
double[] rate = { 5.35, 5.5, 5.75 };
double[] term = { 7.0, 15.0, 30.0 };
for (int i = 0; i < rate.length; ++i)

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 -
Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}


Ok pcbutts1. Since you mentioned DOS, I figure you are no spring chicken
and therefore not a spotty kid too lazy to do the work. Assuming your
difficulty is genuine, here is my way of tackling this problem (to which
Eric Sosman has given a partial solution + java syntax) -

thinking first
principal is 2,000,000
interest is 5.35% per annum
Therefore interest per year is 2000000 x .0535 = 107000
Total interest is 107000 x 7 = 749000
Therefore total to be repaid is 2000000 + 749000 = 2749000
number of months' repayment is 7 x 12 = 84
Thererefore monthly repayment is 32,726.20

answer = ((2000000 * 0.0535 * 7) + 2000000)/(7 * 12)
Now, do a sanity check on the answer (perhaps on a calculator). If it
checks out replace it with the correct java syntax

monthlyPayment = ((principal * (rate[i]/100) * term[i]) + principal) /
(term[i] * 12)

Other things - brush up on arrays, the for statement, indent the code
correctly and figure out when to use double or integers, how to get the
correct display to 2 decimal places.

I am too lazy to check your (1.0 - Math.pow(rate+1,-term)) for what it
means. The syntax is incorrect anyway but if the logic is correct, use it.
Otherwise do the code yourself.

--
Why is the alphabet in that order? Is it because of that song?
-- Steven Wright

Feb 27 '06 #8
pcbutts1 wrote:
I'm sorry but I am still lost. I think it's because I just don't know the
commands or syntax or when or where to use them.


Getting that lost feeling while learning a programming language often
means you need to take a step back.

Redo some earlier exercises. Do exercises from a book or on-line
tutorial. Go back to where you were comfortable, and work forward again
making sure you practice enough to get each point before going on to the
next thing.

Patricia

Feb 27 '06 #9
Patricia Shanahan wrote:
Getting that lost feeling while learning a programming language often
means you need to take a step back.

Redo some earlier exercises. Do exercises from a book or on-line
tutorial. Go back to where you were comfortable, and work forward again
making sure you practice enough to get each point before going on to the
next thing.


Good advice, I recommend the Java 2 'for dummies' book, or even
Beginning program with Java for Dummies if you've never programmed before.
--
Marc
http://www.iMarc.co.uk/ for contact details.
Feb 27 '06 #10
I want to thank you guys for your help and hints, I got it working thanks.

--
The best live web video on the internet http://www.seedsv.com/webdemo.htm
NEW Embedded system W/Linux. We now sell DVR cards.
See it all at http://www.seedsv.com/products.htm
Sharpvision simply the best http://www.seedsv.com

"pcbutts1" <pc******@seedsv.com> wrote in message
news:mu********************@giganews.com...
Yes this is a homework assignment. My instructor has broken english and I
just could not follow along last night. How do I do this

Write the program in Java (without a graphical user interface) and have it
calculate the payment amount for 3 mortgage loans:

a.. 7 year at 5.35%
b.. 15 year at 5.5%
c.. 30 year at 5.75%
Use an array for the different loans. Display the mortgage payment amount
for each loan.
My first one is below that works but how do I do the above

public class wtest
{

public static void main (String[] args)
{
double principal =2000000.0;
double rate =5.75;
double term =30.0;
double monthlyPayment =0.0;

rate = rate/1200.0;
term = term * 12;
monthlyPayment = principal * rate/ (1.0 - Math.pow(rate+1,-term));
System.out.println(monthlyPayment);
}

}
--
The best live web video on the internet http://www.seedsv.com/webdemo.htm
NEW Embedded system W/Linux. We now sell DVR cards.
See it all at http://www.seedsv.com/products.htm
Sharpvision simply the best http://www.seedsv.com

Mar 3 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
5
by: John Flynn | last post by:
hi all i'm going to be quick i have an assignment due which i have no idea how to do. i work full time so i dont have the time to learn it and its due date has crept up on me .. As follows:...
0
by: xunling | last post by:
i have a question about answering ..... this topic is "need help" what do i have to write at te topic line, !after i have klicked the "answer message" button ive tried many possibilities,...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.