Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PD:2nd
- //Chapter,5#13
- import javax.swing.*;
- public class PetAdvice
- {
- public static void main (String[] args)
- {
- String response = JOptionPane.showInputDialog(null, "Please pick which kind of place do you live in:\n A-Aparment\n H-House\n D-Dormitory");
- String response2 = JOptionPane.showInputDialog(null, " Please pick number of hours user is home during the average day:\n A-18 or more\n B-10 to 17\n C-8 to 9\n D-6 to 7\n E-0 to 5");
- char home = response.charAt(0);
- char hour = response2.charAt(0);
- switch(home)
- {
- case 'H':
- case 'h':
- switch (hour)
- {
- case 'A':
- case 'a':
- JOptionPane.showMessageDialog(null,"Your pet would be a Pot bellied pig");
- break;
- case 'b':
- case 'B':
- JOptionPane.showMessageDialog(null,"your pet would be a Dog");
- break;
- case 'c':
- case 'C':
- JOptionPane.showMessageDialog(null,"your pet would be a snake");
- break;
- default:
- JOptionPane.showMessageDialog(null,"Invalid entry!");
- }
- break;
- case 'A':
- case 'a':
- switch (hour)
- {
- case 'B':
- case 'b':
- JOptionPane.showMessageDialog(null,"your pet would be a Cat");
- break;
- case 'C':
- case 'c':
- JOptionPane.showMessageDialog(null,"your pet would be a Hamster");
- break;
- default:
- JOptionPane.showMessageDialog(null,"Invalid entry!");
- }
- break;
- case'D':
- case'd':
- switch (hour)
- {
- case 'D':
- case 'd':
- JOptionPane.showMessageDialog(null,"your pet would be a Fish");
- break;
- case'E':
- case'e':
- JOptionPane.showMessageDialog(null,"your pet would be a Ant Farm");
- break;
- default:
- JOptionPane.showMessageDialog(null,"Invalid entry!");
- }
- break;
- default:
- JOptionPane.showMessageDialog(null,"Invalid entry!");
- }
- Ending.last("Chapter 5 #17 4/15/09");
- }
- }
Add Comment
Please, Sign In to add comment