Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.38 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class assign9a1
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         //----int---//
  8.        
  9.         int n=0;
  10.         int c=0;
  11.        
  12.         Object[ ] options1={"The Moon","An Elephant","A Mountain","A Cup Of Water"};
  13.         Object[ ] tf1={"True","False"};
  14.        
  15.         //---1---//
  16.        
  17.         n = JOptionPane.showOptionDialog(null,
  18.     "Which of the following is the largest?",
  19.     "Question 1",
  20.     JOptionPane.YES_NO_CANCEL_OPTION,
  21.     JOptionPane.QUESTION_MESSAGE,
  22.     null,
  23.     options1,
  24.     options1[0]);
  25.    
  26.         if(n!=0)
  27.         {
  28.             JOptionPane.showMessageDialog( null, "Incorrect,  the correct choice was Choice 1,  The Moon.","Incorrect",JOptionPane.ERROR_MESSAGE);
  29.             n=0;
  30.         }
  31.         else
  32.         {
  33.             JOptionPane.showMessageDialog( null,"Correct.","Correct",JOptionPane.INFORMATION_MESSAGE);
  34.             c++;
  35.             n=0;
  36.         }
  37.        
  38.         //---2---//
  39.        
  40.         n = JOptionPane.showOptionDialog(null,
  41.     "True or False: You are currently on Question 2.",
  42.     "Question 2",
  43.     JOptionPane.YES_NO_CANCEL_OPTION,
  44.     JOptionPane.QUESTION_MESSAGE,
  45.     null,
  46.     tf1,
  47.     tf1[0]);
  48.    
  49.         if(n!=0)
  50.         {
  51.             JOptionPane.showMessageDialog( null, "Incorrect,  the correct choice was Choice 1,  True.","Incorrect",JOptionPane.ERROR_MESSAGE);
  52.             n=0;
  53.         }
  54.         else
  55.         {
  56.             JOptionPane.showMessageDialog( null,"Correct.","Correct",JOptionPane.INFORMATION_MESSAGE);
  57.             c++;
  58.             n=0;
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement