The Artima Developer Community
Sponsored Link

Java Answers Forum
Big help request

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
orava otus

Posts: 1
Nickname: orava
Registered: Jan, 2008

Big help request Posted: Jan 16, 2008 5:42 AM
Reply to this message Reply
Advertisement
Soo.. I have this programming thing for school and im gettin reallly frustrated coz i just wont get
it.
I managed to make some basic stuff, which is nothing like required or not even pretty
coding.
So here is what the program should do:

1. Asks from user amount of loan, yearly intrest and monthly payment and stores this info to
array(s) (and arrays confused the heck out of me)
2. Checks that the info the user inputted is ok (numbers, bigger than 0, monthly payment is bigger
than first months intrest(if not it chages monthly payment to first months intrest + 1)
3. Then asks the user if he wants to input other combination (Yes/No) if answer is yes it does
the steps 1 and 2 again (and again and again), if answer is no, goes to step 4
4. calculates how long it takes to pay the loan back, how much were total intrests, how much was
total cost (loan + intrests)
5. Prints out the info from all combinations AND writes same info in text file
Out put would look like this:
1. loan
loan amount: 1000 euro
intrest: 10 %
monthly payment: 100 euro
total intrests: 48,6 euro
total cost: 1048,6 euro
time: 0 year 11 months

2. loan
loan amount: 1200 euro
intrest: 15 %
monthly payment: 90 euro
total intrests: 121 euro
total cost: 1321 euro
time: 1 year 3 months

And ofc it should be nice and tidy, so that stuff is in differetn methods, rather than all in main,
but again that was something i couldnt figure out. and ofcourse it only needs 1 decimal or no
decimals at all.

So if someone would have some free time in their hands to find time to help this girl out,
you would have my eternal grattitude and admiration :)
I know its askin a lot so if u feel like im out of the line, just ignore me, thanks all.

This is what i got done:

import java.io.*;

public class loancalc {

public static void main (String args[]) throws Exception {

BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System.in ));

double loan, originalloan, intrest, payment, decintrest;

System.out.print("Give loan amount: ");
loan = Double.parseDouble( stdin.readLine() );
originalloan = loan;

System.out.print("Give yearly intrest without %-mark: ");
intrest = Double.parseDouble(stdin.readLine() );
decintrest=intrest/100;

System.out.print("Give monthly payment: ");
payment = Double.parseDouble(stdin.readLine() );

double firstintrest;

firstintrest = loan * decintrest / 12;

if (payment < firstintrest) {
System.out.println("Monthyly payment cant be smaller than first month intrests");
payment = firstintrest + 1;
System.out.println("Minimun payment is " + payment + " euro");
System.out.println("Calculating with minimum payment.");
}

int time = 0;
double loanintrest;
double totalintrest = 0;
double totalcost;

do {
loanintrest = loan * decintrest / 12;
loan = loan + loanintrest;
loan = loan - payment;
totalintrest = totalintrest + loanintrest;
time++;
}

while (loan > 0);

totalcost = originalloan + totalintrest;

System.out.println( );
System.out.println("Loan");
System.out.println("-------------");
System.out.println("Loan: " + originalloan + " euro");
System.out.println("Loan intrest: " + intrest + " %");
System.out.println("Monthly payment " + payment + " euro");
System.out.println("Totalinrests: " + totalintrest + " euro" );
System.out.println("Total cost: " + totalcost + " euroa" );
System.out.println("Time: " + time + " months" );



}
}

Topic: Big help request Previous Topic   Next Topic Topic: How do I convert a Big-Endian(64 bit) to Little Endian(64 bit) in Java.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use