gan ane bingung nih tentang program java ini, ane disuruh bikin simulasi kredit perhitungan buat motor nih gan. pas di switch case nya, variabel yg ane buat kok gak masuk ya, malah nginput yang di joptionnya. coba deh gan di koreksi
tolongin ya gan. pleaseee
nih filenya :
[SPOILER]
Quote:
import javax.swing.*;
class tugasusah {
public static void main (String[]args) {
int miocw = 12950000, mioteen = 13100000, soul = 14050000;
JOptionPane.showMessageDialog
(null, "PROGRAM SIMULASI KREDIT MOTOR \n by Angga Pradipta" , "Welcome",
JOptionPane.PLAIN_MESSAGE);
String a = JOptionPane.showInputDialog ("Daftar Motor \n 1. Mio J CW FI Rp. 12.950.000 \n 2. Mio J CW TEEN FI Rp. 13.100.000 \n 3. Soul GT Rp. 14.050.000 ");
int x = Integer.parseInt(a);
switch(x) {
case 1 : if (1 == (miocw))
JOptionPane.showMessageDialog (
null, "Anda memilih Mio J CW FI seharga "+miocw, "Pilihan anda",
JOptionPane.PLAIN_MESSAGE);break;
case 2 : if (x == 2)
JOptionPane.showMessageDialog (
null, "Anda memilih Mio J CW TEEN FI seharga "+mioteen, "Pilihan anda",
JOptionPane.PLAIN_MESSAGE);break;
case 3 : if (x == 3)
JOptionPane.showMessageDialog (
null, "Anda memilih Soul GT seharga "+soul, "Pilihan anda",
JOptionPane.PLAIN_MESSAGE);break;
default : JOptionPane.showMessageDialog (null, " Anda Salah Pilih ", "Warning!!!",
JOptionPane.PLAIN_MESSAGE); System.exit ( 0 );
}
String b = JOptionPane.showInputDialog ( " Masukkan uang mukanya " );
int dp = Integer.parseInt(b);
String c = JOptionPane.showInputDialog ( " Berapa lama angsuran yang anda inginkan " , "lama bulan");
int angsur = Integer.parseInt(c);
int hasil = (x - dp) / angsur;
JOptionPane.showMessageDialog (null, "Yang harus anda bayar Rp "+x , "Warning!!!",
JOptionPane.PLAIN_MESSAGE); System.exit ( 0 );
}
}
[/SPOILER]