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 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
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
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
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
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
"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); }
}
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
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
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.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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,...
|
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:...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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 ...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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...
| |