import java.io.*;
class finalproject_InterestRate
{
public static void main
(String[]text
)
{
try{
double amount;
double interestRate
[]=
new double[3];
DataInput d =
new DataInputStream(System.
in);
String txt;
System.
out.
println("\n" +
"We are offering loans upto $50000 at good rates so if anyone is looking for a loan we are here for you.");
System.
out.
println("\n" +
"How much money do you want to borrow?.");
amount=
Double.
parseDouble(d.
readLine());
if (amount<=
10000)
{
System.
out.
print("\n" +
"The interest rate you are borrowing at is ");
System.
out.
print(interestRate
[0]=
5);
System.
out.
println(" %.");
interestRate
[0]/=
100;
interestRate
[0]+=
1;
System.
out.
println(interestRate
[0]);
}
else if ((amount>
10000) &&
(amount<=
20000))
{
System.
out.
print("\n" +
"The interest rate you are borrowing at is ");
System.
out.
print(interestRate
[1]=
10);
System.
out.
println(" %.");
interestRate
[1] /=
100;
interestRate
[1] +=
1;
System.
out.
println(interestRate
[1]);
}
else if ((amount>
20000) &&
(amount<=
50000))
{
System.
out.
print("\n" +
"The interest rate you are borrowing at is ");
System.
out.
print(interestRate
[2]=
15);
System.
out.
println(" %.");
interestRate
[2]/=
100;
interestRate
[2]+=
1;
System.
out.
println(interestRate
[2]);
}
else
System.
out.
println("Too much money");
System.
out.
println("For how long would you like the loan for.");
System.
out.
println("Your options are 1 year, 2 years, 5 years, or 10 years.");
int time=
Integer.
parseInt(d.
readLine());
if (time==
1)
{
System.
out.
print("\n" +
"You will have to pay interest for 1 year, compounded monthly, for ");
System.
out.
print(time*=
12);
System.
out.
println(" periods.");
}
else if (time==
2)
{
System.
out.
print("\n" +
"You will have to pay interest for 2 years, compounded quartly, for ");
System.
out.
print(time*=
3);
System.
out.
println(" periods.");
}
else if (time==
5)
{
System.
out.
print("\n" +
"You will have to pay interest for 5 years compounded Semi annually, for ");
System.
out.
print(time*=
2);
System.
out.
println(" periods.");
}
else if (time==
10)
{
System.
out.
print("\n" +
"You will have to pay interest for 10 years, annually, for ");
System.
out.
print(time*=
1);
System.
out.
println(" periods.");
}
else
System.
out.
println("We dont offer that year.");
double amountPayment;
System.
out.
println("\n" +
"How much money will you pay each period?");
amountPayment=
Double.
parseDouble(d.
readLine());
System.
out.
println("I would like to pay $ " + amountPayment +
"\n");
double totalPayment;
double interestPayment=
0;
int period=
1;
if (amount<=
10000)
{
for(int interestPeriod=
1; interestPeriod<=time; interestPeriod++
)
{
System.
out.
println("\nYour interest payment is $" +
(interestPayment=
((amount*interestRate
[0])-amount
)));
System.
out.
print("Your total payment is $");
System.
out.
println(totalPayment=interestPayment+amountPayment
);
System.
out.
print("You still have to pay $");
System.
out.
println(amount-=amountPayment
);
}
}
if (amount>
10000 && amount<=
20000)
{
for(int interestPeriod=
1; interestPeriod<=time; interestPeriod++
)
{
System.
out.
println("\nYour interest payment is $" +
(interestPayment=
((amount*interestRate
[1])-amount
)));
System.
out.
print("Your total payment is $");
System.
out.
println(totalPayment=interestPayment+amountPayment
);
System.
out.
print("You still have to pay $");
System.
out.
println(amount-=amountPayment
);
}
}
if (amount>
20000 && amount<=
50000)
{
for(int interestPeriod=
1; interestPeriod<=time; interestPeriod++
)
{
System.
out.
println("\nYour interest payment is $" +
(interestPayment=
((amount*interestRate
[2])-amount
)));
System.
out.
print("Your total payment is $");
System.
out.
println(totalPayment=interestPayment+amountPayment
);
System.
out.
print("You still have to pay $");
System.
out.
println(amount-=amountPayment
);
}
}
}catch (IOException ignored
){}
}
}