-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathInvest.java
More file actions
50 lines (41 loc) · 1.34 KB
/
Invest.java
File metadata and controls
50 lines (41 loc) · 1.34 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package invest;
import javax.swing.JOptionPane;
/**
*
* @author cwr
*/
public class Invest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
float awal,bunga,laba = 0,invest;
double tambah,total = 0;
int bulan;
String hasil = null;
awal = Integer.valueOf(JOptionPane.showInputDialog(null, "Investasi Awal (Rp):"));
bulan = Integer.valueOf(JOptionPane.showInputDialog(null, "Saldo Bulan ke:"));
bunga = 2/100;
invest = awal;
for(int i=0; i<bulan; i++){
laba = invest*2/100;
total = invest + laba;
invest = invest + laba;
}
// Untuk membulatkan hasil
tambah = 0.5;
total = total + tambah;
/////
hasil="========= Investasi =========\n"+
"Investasi Awal: Rp. "+awal+"\n"+
"Saldo Bulan ke- "+bulan+"\n"+
"Rp. "+total+"\n"+
"==========================";
JOptionPane.showMessageDialog(null, hasil);
}
}