Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class assign9a1
- {
- public static void main(String[] args)
- {
- //----int---//
- int n=0;
- int c=0;
- Object[ ] options1={"The Moon","An Elephant","A Mountain","A Cup Of Water"};
- Object[ ] tf1={"True","False"};
- //---1---//
- n = JOptionPane.showOptionDialog(null,
- "Which of the following is the largest?",
- "Question 1",
- JOptionPane.YES_NO_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null,
- options1,
- options1[0]);
- if(n!=0)
- {
- JOptionPane.showMessageDialog( null, "Incorrect, the correct choice was Choice 1, The Moon.","Incorrect",JOptionPane.ERROR_MESSAGE);
- n=0;
- }
- else
- {
- JOptionPane.showMessageDialog( null,"Correct.","Correct",JOptionPane.INFORMATION_MESSAGE);
- c++;
- n=0;
- }
- //---2---//
- n = JOptionPane.showOptionDialog(null,
- "True or False: You are currently on Question 2.",
- "Question 2",
- JOptionPane.YES_NO_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null,
- tf1,
- tf1[0]);
- if(n!=0)
- {
- JOptionPane.showMessageDialog( null, "Incorrect, the correct choice was Choice 1, True.","Incorrect",JOptionPane.ERROR_MESSAGE);
- n=0;
- }
- else
- {
- JOptionPane.showMessageDialog( null,"Correct.","Correct",JOptionPane.INFORMATION_MESSAGE);
- c++;
- n=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement