Advertisement
Guest User

Quiz

a guest
Mar 5th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class Elektronisches_Quiz_II_lw {
  4.  
  5.     public static void main(String[] args) throws Exception{
  6.        
  7.         double x = Math.ceil(Math.random()*2);
  8.         String joker [] = {"A: Konrad Adenauer, D: Ludwig Erhard","B: Kurt Georg Kiesinger, D: Ludwig Erhard","C: Willy Brandt, D: Ludwig Erhard"};
  9.        
  10.         wiederholen:for(;;){
  11.         String auswahl1 = JOptionPane.showInputDialog("Wer war der 2. Bundeskanzler der Bundesrepublik Deutschland?\n"
  12.                                     +"A: Konrad Adenauer, B: Kurt Georg Kiesinger, C: Willy Brandt, D: Ludwig Erhard, J: 50/50 Joker");            
  13.        
  14.        
  15.         switch(auswahl1){      
  16.             case "A":
  17.             case "B":
  18.             case "C": JOptionPane.showMessageDialog(null,"Falsch!");
  19.                 break wiederholen;
  20.             case "D": JOptionPane.showMessageDialog(null,"Richtig!");
  21.                 break wiederholen;
  22.             case "J":String auswahl2 = JOptionPane.showInputDialog(joker[(int)x]);         
  23.             switch(auswahl2){
  24.                 case "A":
  25.                 case "B":
  26.                 case "C": JOptionPane.showMessageDialog(null,"Falsch!");
  27.                     break wiederholen;
  28.                 case "D": JOptionPane.showMessageDialog(null,"Richtig!");
  29.                     break wiederholen;
  30.                 }
  31.             default: continue wiederholen;
  32.                
  33.             }
  34.         }  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement