import java.io.*;
import javax.swing.*;
class menu{
public static void main(String[]args){
do{
String temp = JOptionPane.showInputDialog("menu\n1.biodata\n2.grade\n
3.deret\n4.Matriks\n5.keluar");
int pil = Integer.parseInt(temp);
switch(pil)
{
case 1:
{
String nama = JOptionPane.showInputDialog("masukkan nama:");
String npm = JOptionPane.showInputDialog("masukkan npm:");
String kelas = JOptionPane.showInputDialog("masukkan kelas:");
JOptionPane.showMessageDialog(null,"nama : "+nama+"\n, npm
:"+npm+"\n,kelas :"+kelas);
}
break;
case 2:
{
int uts = Integer.parseInt(JOptionPane.showInputDialog("masukan nilai uts :"));
int uas = Integer.parseInt(JOptionPane.showInputDialog("masukan nilai uas :"));
double total = (uts*0.7)+(uas*0.3);
if((total>=80)&&(total<=90))
{
JOptionPane.showMessageDialog(null,"nilai akhir anda : "+total+"\n anda lulus
dengan grade A");
}
else if((total>=70)&&(total<=79))
{
JOptionPane.showMessageDialog(null,"nilai akhir anda : "+total+"\n anda lulus
dengan grade B");
}
else if((total>=60)&&(total<=69))
{
JOptionPane.showMessageDialog(null,"nilai akhir anda : "+total+"\n anda lulus
dengan grade C");
}
else if((total>=50)&&(total<=59))
{
JOptionPane.showMessageDialog(null,"nilai akhir anda : "+total+"\n anda lulus
dengan grade D");
}
else
{
JOptionPane.showMessageDialog(null,"nilai akhir anda : "+total+"\n anda lulus
dengan grade E");
}
}
break;
case 3:
{
int deret = Integer.parseInt(JOptionPane.showInputDialog("masukkan nilai deret:
"));
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:
{
String[][]bil=new String[3][3];
int[][]a=new int[2][2];
int[][]b=new int[2][2];
int[][]c=new int[2][2];
for (int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
bil[i][j]=JOptionPane.showInputDialog("Elemen Matriks A["+i+"]["+j+"]");
a[i][j]=Integer.parseInt(bil[i][j]);
}
}
for (int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
bil[i][j]=JOptionPane.showInputDialog("Elemen Matriks B["+i+"]["+j+"]");
b[i][j]=Integer.parseInt(bil[i][j]);
c[i][j]=(a[i][j]+b[i][j]);
}
}
JOptionPane.showMessageDialog(null,"Matriks A\n"+a[0][0]+"
"+a[0][1]+"\n"+a[1][0]+" "+a[1][1]);
JOptionPane.showMessageDialog(null,"Matriks B\n"+b[0][0]+"
"+b[0][1]+"\n"+b[1][0]+" "+b[1][1]);
JOptionPane.showMessageDialog(null,"Matriks C=A+B\n"+a[0][0]+"
"+a[0][1]+"\n"+a[1][0]+" "+a[1][1]+"\n+ "+"\n"+b[0][0]+"
"+b[0][1]+"\n"+b[1][0]+" "+b[1][1]+"\n= "+"\n"+c[0][0]+"
"+c[0][1]+"\n"+c[1][0]+" "+c[1][1]);
}
break;
case 5:
{
System.exit(0);
}
default:
{
JOptionPane.showMessageDialog(null,"Input yang anda masukkan salah");
}
}
}
while(true);
}
}
0 komentar:
Posting Komentar