```
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);
}
}
```

## Recommended Answers

Jump to Post"won't work" tells us nothing. Next time post the

completetext of your error messages.

Anyway, your variables daily,weekly,quaterly,bianually,yearly are not initialised.

## All 3 Replies

JamesCherrill
4,319
Most Valuable Poster
Moderator
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 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.