/*========================================================================
programmer: hendra silaban
nama file : input data
tanggal : 25 nov 2011
deskripsi : -menginput data
-penggunaan swith case didalam switch ========================================================================*/
import javax.swing.JOptionPane;
class DreamTeam
{
public static void main(String[] args)
{
String namaclubS;
int namaclub;
String realmadridS;
int realmadrid;
String man_cityS;
int man_city;
String liverpoolS;
int liverpool;
String man_unitedS;
int man_united;
do{
namaclubS = JOptionPane.showInputDialog("NAMA TEAM YANG ANDA PILIH :\n1.REALMADRID\n2.MAN.CITY\n3.LIVERPOOL\n4.MAN.UNITED");
namaclub = Integer.parseInt(namaclubS);
}while(namaclub < 1 || namaclub > 4);
switch (namaclub)
{
case 1:JOptionPane.showMessageDialog(null,"REALMADRID");
do{
realmadridS = JOptionPane.showInputDialog("NAMA PEMAIN REALMADRID :\n1.C.RONALDO\n2.KAKA\n3.PEPE\n4.IKER CASILAS");
realmadrid = Integer.parseInt(realmadridS);
}while(realmadrid < 1 || realmadrid > 4);
switch(realmadrid)
{
case 1:JOptionPane.showMessageDialog(null,"C.RONALDO\n(posisi : STRIKER/WINGER)");
break;
case 2:JOptionPane.showMessageDialog(null,"KAKA\n(posisi : PLAYMAKER)");
break;
case 3:JOptionPane.showMessageDialog(null,"PEPE\n(posisi : CENTRAL DEFENDER)");
break;
case 4:JOptionPane.showMessageDialog(null,"IKER CASILAS\n(posisi : GOALKEEPER)");
break;
}
break;
case 2:JOptionPane.showMessageDialog(null,"MAN.CITY");
do{
man_cityS = JOptionPane.showInputDialog("NAMA PEMAIN MAN.CITY :\n1.DZEKO\n2.NASRI\n3.COMPANY\n4.HART");
man_city = Integer.parseInt(man_cityS);
}while(man_city < 1 || man_city > 4);
switch(man_city)
{
case 1:JOptionPane.showMessageDialog(null,"DZEKO\n(posisi : STRIKER)");
break;
case 2:JOptionPane.showMessageDialog(null,"NASRI\n(posisi : PLAYMAKER)");
break;
case 3:JOptionPane.showMessageDialog(null,"COMPANY\n(posisi : CENTRAL DEFENDER)");
break;
case 4:JOptionPane.showMessageDialog(null,"HART\n(posisi : GOALKEEPER)");
break;
}
break;
case 3:JOptionPane.showMessageDialog(null,"LIVERPOOL");
do{
liverpoolS = JOptionPane.showInputDialog("NAMA PEMAIN LIVERPOOL :\n1.L.SUAREZ\n2.GERRAD\n3.SKRTEL\n4.PEPE REINA");
liverpool = Integer.parseInt(liverpoolS);
}while(liverpool < 1 || liverpool > 4);
switch(liverpool)
{
case 1:JOptionPane.showMessageDialog(null,"L.SUAREZ\n(posisi : STRIKER/WINGER)");
break;
case 2:JOptionPane.showMessageDialog(null,"GERRAD\n(posisi : PLAYMAKER)");
break;
case 3:JOptionPane.showMessageDialog(null,"SKRTEL\n(posisi : CENTRAL DEFENDER)");
break;
case 4:JOptionPane.showMessageDialog(null,"PEPE REINA\n(posisi : GOALKEEPER)");
break;
}
break;
case 4:JOptionPane.showMessageDialog(null,"MAN.UNITED");
do{
man_unitedS = JOptionPane.showInputDialog("NAMA PEMAIN MAN.UNITED :\n1.ROONEY\n2.NANI\n3.JONES\n4.DE GEA");
man_united = Integer.parseInt(man_unitedS);
}while(man_united < 1 || man_united > 4);
switch(man_united)
{
case 1:JOptionPane.showMessageDialog(null,"ROONEY\n(posisi : STRIKER)");
break;
case 2:JOptionPane.showMessageDialog(null,"NANI\n(posisi : PLAYMAKER/WINGER)");
break;
case 3:JOptionPane.showMessageDialog(null,"JONES\n(posisi : CENTRAL DEFENDER)");
break;
case 4:JOptionPane.showMessageDialog(null,"DE GEA\n(posisi : GOALKEEPER)");
break;
}
break;
}
}
}
Tidak ada komentar:
Posting Komentar