-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculateinterest.java
More file actions
27 lines (26 loc) · 849 Bytes
/
calculateinterest.java
File metadata and controls
27 lines (26 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.Scanner;
public class calculateinterest
{
public static void main(String [] args)
{
calculateInterest(1000.0,0.04);
calculateInterest(1000.0,5);
calculateInterest(1000,0.06);
calculateInterest(1000,7);
}
public static void calculateInterest(double bal, double rate)
{
double interest;
interest = bal * rate;
System.out.println("Simple interest on $" +bal+ " at "+
(int)(rate)+ "% is " +(double)interest);
}
public static void calculateInterest( double bal, int rate)
{
double interest, rateAsPercent;
rateAsPercent = rate / 100.0;
interest = bal * rateAsPercent;
System.out.println("Simple interest on $" +bal+ " at "+
(int)(rate)+ "% is " +(double)interest);
}
}