import java.util.Scanner;
import java.util.*;
public class Interest {
public static void main(String[]args)
{
double
interest,
primary,
period,
amount,
yearly,
monthly,
daily,
weekly,
quaterly,
bianually,
time;
Scanner Scanner = new Scanner(System.in);
System.out.println(" How much money is the person wanting to loan?");
primary = Scanner.nextInt();
System.out.println("Please enter the rate of interest.");
interest = Scanner.nextInt();
System.out.println("Over how many years will they pay the loan back?");
time = Scanner.nextInt();
System.out.println("Do you wish to have this amount compounded daily, weekly,");
System.out.println("quaterly, bianually or yearly?");
period = Scanner.nextInt();
if
(period == daily)
amount = primary*Math.pow(1.0 + interest/365, time*365);
if
(period == weekly)
amount = primary*Math.pow(1.0 + interest/52, time*52);
if
(period == quaterly)
amount = primary*Math.pow(1.0 + interest/4, time*4);
if
(period == bianually)
amount = primary*Math.pow(1.0 + interest/2, time*2);
if
(period == yearly)
amount = primary*Math.pow(1.0 + interest, time);
System.out.println("Your final amount is R" + amount);
}
}
// Stuck, Please help
import java.util.Scanner;
import java.util.*;
public class Interest {
public static void main(String[]args)
{
double
interest,
primary,
period,
amount,
yearly,
monthly,
daily,
weekly,
quaterly,
bianually,
time;
Scanner Scanner = new Scanner(System.in);
System.out.println(" How much money is the person wanting to loan?");
primary = Scanner.nextInt();
System.out.println("Please enter the rate of interest.");
interest = Scanner.nextInt();
System.out.println("Over how many years will they pay the loan back?");
time = Scanner.nextInt();
System.out.println("Do you wish to have this amount compounded daily, weekly,");
System.out.println("quaterly, bianually or yearly?");
period = Scanner.nextInt();
if
(period == daily)
amount = primary*Math.pow(1.0 + interest/365, time*365);
if
(period == weekly)
amount = primary*Math.pow(1.0 + interest/52, time*52);
if
(period == quaterly)
amount = primary*Math.pow(1.0 + interest/4, time*4);
if
(period == bianually)
amount = primary*Math.pow(1.0 + interest/2, time*2);
if
(period == yearly)
amount = primary*Math.pow(1.0 + interest, time);
System.out.println("Your final amount is R" + amount);
}
}
psy.blast 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Starstreak 13 Light Poster
steph7 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.