Guest User

Untitled

a guest
Oct 10th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. Title: Quiz #4
  2. Author: Terry Weiss
  3. Date: 10/14/15
  4. Course & Section: CSC 111-003W
  5.  
  6. Description: This program prompts the User to enter a month and then displays how many days are in that month.
  7.  
  8. Initial Algorithm
  9. Prompt for the month until given a valid input
  10. Determine correct month and the correct name of the month
  11. Display the name of the month in Title Case and the number of days in that month
  12.  
  13. Data Requirements:
  14. Input:
  15. (String) month – This is the month inputted by the User
  16. Output:
  17. (String) month – This is the month after it’s been formatted to the correct month name in Title Case
  18. (String) days – This is the number of days in the month
  19. Additional Variables:
  20. (boolean) validInput – This notifies the loop as to whether valid input has been entered
  21.  
  22. Formulas:
  23. N/A
  24.  
  25. Refined Algorithm
  26. Initialize validInput = true
  27. DO
  28. Get the month in lower case {to have case insensitive input}
  29.  
  30. IF month == “1” OR month == “jan” OR month == “january” THEN
  31. month = “January”
  32. days = “31”
  33. ELSE IF month == “2” OR month == “feb” OR month == “february” THEN
  34. month = “February”
  35. days = “28 or 29”
  36. ELSE IF month == “3” OR month == “mar” OR month == “march” THEN
  37. month = “March”
  38. days = “31”
  39.  
  40. ELSE IF month == “4” OR month == “apr” OR month == “april” THEN
  41. month = “April”
  42. days = “30”
  43. ELSE IF month == “5” OR month == “may” THEN
  44. month = “May”
  45. days = “31”
  46. ELSE IF month == “6” OR month == “jun” OR month == “june” THEN
  47. month = “June”
  48. days = “30”
  49. ELSE IF month == “7” OR month == “jul” OR month == “july” THEN
  50. month = “July”
  51. days = “31”
  52. ELSE IF month == “8” OR month == “aug” OR month == “august” THEN
  53. month = “August”
  54. days = “31”
  55. ELSE IF month == “9” OR month == “sept” OR month == “september” THEN
  56. month = “September”
  57. days = “30”
  58. ELSE IF month == “10” OR month == “oct” OR month == “october” THEN
  59. month = “October”
  60. days = “31”
  61. ELSE IF month == “11” OR month == “nov” OR month == “november” THEN
  62. month = “November”
  63. days = “30”
  64. ELSE IF month == “12” OR month == “dec” OR month == “december” THEN
  65. month = “December”
  66. days = “31”
  67. ELSE
  68. Display error about invalid month being entered
  69. validInput = false
  70. LOOP UNTIL validInput
  71.  
  72. Display the month and the number of days it has
Advertisement
Add Comment
Please, Sign In to add comment