Guest User

Untitled

a guest
Jun 13th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1.  
  2. //PD:2nd
  3. //Chapter,5#13
  4.  
  5.  
  6. import javax.swing.*;
  7. public class PetAdvice
  8. {
  9. public static void main (String[] args)
  10. {
  11. String response = JOptionPane.showInputDialog(null, "Please pick which kind of place do you live in:\n A-Aparment\n H-House\n D-Dormitory");
  12. 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");
  13. char home = response.charAt(0);
  14. char hour = response2.charAt(0);
  15. switch(home)
  16. {
  17. case 'H':
  18. case 'h':
  19. switch (hour)
  20. {
  21. case 'A':
  22. case 'a':
  23. JOptionPane.showMessageDialog(null,"Your pet would be a Pot bellied pig");
  24. break;
  25. case 'b':
  26. case 'B':
  27. JOptionPane.showMessageDialog(null,"your pet would be a Dog");
  28. break;
  29. case 'c':
  30. case 'C':
  31. JOptionPane.showMessageDialog(null,"your pet would be a snake");
  32. break;
  33. default:
  34. JOptionPane.showMessageDialog(null,"Invalid entry!");
  35.  
  36. }
  37. break;
  38.  
  39. case 'A':
  40. case 'a':
  41. switch (hour)
  42. {
  43. case 'B':
  44. case 'b':
  45. JOptionPane.showMessageDialog(null,"your pet would be a Cat");
  46. break;
  47. case 'C':
  48. case 'c':
  49. JOptionPane.showMessageDialog(null,"your pet would be a Hamster");
  50. break;
  51. default:
  52. JOptionPane.showMessageDialog(null,"Invalid entry!");
  53.  
  54.  
  55. }
  56. break;
  57. case'D':
  58. case'd':
  59. switch (hour)
  60. {
  61. case 'D':
  62. case 'd':
  63. JOptionPane.showMessageDialog(null,"your pet would be a Fish");
  64. break;
  65. case'E':
  66. case'e':
  67. JOptionPane.showMessageDialog(null,"your pet would be a Ant Farm");
  68. break;
  69. default:
  70. JOptionPane.showMessageDialog(null,"Invalid entry!");
  71.  
  72.  
  73.  
  74.  
  75.  
  76. }
  77. break;
  78. default:
  79. JOptionPane.showMessageDialog(null,"Invalid entry!");
  80.  
  81.  
  82.  
  83.  
  84. }
  85.  
  86. Ending.last("Chapter 5 #17 4/15/09");
  87.  
  88. }
  89. }
Add Comment
Please, Sign In to add comment