Coding program :
import java.io.*;
import javax.swing.*;
class menu
{
public static void main(String[]args)
{
do
{
String temp = JOptionPane.showInputDialog ("----=| MENU |=---- \n1. Biodata \n2. Nilai UTS UAS \n3. Deret \n4. Keluar");
int pilihan = Integer.parseInt(temp);
{
case 1:
String nama = JOptionPane.showInputDialog("Masukkan Nama Anda :");
String npm = JOptionPane.showInputDialog("Masukkan NPM Anda :");
String kelas = JOptionPane.showInputDialog("Masukkan Kelas Anda :");
JOptionPane.showMessageDialog(null, "Nama "+nama+ "\n Npm "+npm+ "\n Kelas "+kelas);
break;
case 2 :
String temp1 = JOptionPane.showInputDialog("Masukkan Nilai UTS : ");
int uts = Integer.parseInt(temp1);
String temp2 = JOptionPane.showInputDialog("Masukkan Nilai UAS : ");
int uas = Integer.parseInt(temp2);
double total = (uts*0.7)+(uas*0.3);
if ((total>=80)&&(total<=90))
{
JOptionPane.showMessageDialog(null,"Nilai Akhir Anda :"+total+"\nAnda Lulus dengan nilai A");
}
else if ((total>=70)&&(total<=79))
{
JOptionPane.showMessageDialog(null,"Nilai Akhir Anda :"+total+"\nAnda Lulus dengan nilai B");
}
else if ((total>=60)&&(total<=69))
{
JOptionPane.showMessageDialog(null,"Nilai Akhir Anda :"+total+"\nAnda Lulus dengan nilai C");
}
else if ((total>=50)&&(total<=59))
{
JOptionPane.showMessageDialog(null,"Nilai Akhir Anda :"+total+"\nAnda Lulus dengan nilai D");
}
else
{
JOptionPane.showMessageDialog(null,"Nilai Akhir Anda :"+total+"\nAnda Lulus dengan nilai E");
}
break;
case 3 :
String temp3 = JOptionPane.showInputDialog (" Masukkan Jumlah Deret:");
int deret =Integer.parseInt(temp3);
String hasil = " ";
for (int i = 1 ;i<= deret ;i++ )
{
for (int j = 1;j<= i ;j++ )
{
hasil = hasil+j;
}
hasil = hasil+"\n";
}
JOptionPane.showMessageDialog(null,hasil);
break;
case 4 :
JOptionPane.showMessageDialog(null,"Terimakasih");
System.exit(0);
break;
default :
JOptionPane.showMessageDialog(null,"Pilihan Hanya 1 s/d 4!!!");
}
while(true);
}
}
0 komentar:
Posting Komentar