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 6259
(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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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,...
|
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...
| |