Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
83
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. ELSE IF month == “4” OR month == “apr” OR month == “april” THEN
  40. month = “April”
  41. days = “30”
  42. ELSE IF month == “5” OR month == “may” THEN
  43. month = “May”
  44. days = “31”
  45. ELSE IF month == “6” OR month == “jun” OR month == “june” THEN
  46. month = “June”
  47. days = “30”
  48. ELSE IF month == “7” OR month == “jul” OR month == “july” THEN
  49. month = “July”
  50. days = “31”
  51. ELSE IF month == “8” OR month == “aug” OR month == “august” THEN
  52. month = “August”
  53. days = “31”
  54. ELSE IF month == “9” OR month == “sept” OR month == “september” THEN
  55. month = “September”
  56. days = “30”
  57. ELSE IF month == “10” OR month == “oct” OR month == “october” THEN
  58. month = “October”
  59. days = “31”
  60. ELSE IF month == “11” OR month == “nov” OR month == “november” THEN
  61. month = “November”
  62. days = “30”
  63. ELSE IF month == “12” OR month == “dec” OR month == “december” THEN
  64. month = “December”
  65. days = “31”
  66. ELSE
  67. Display error about invalid month being entered
  68. validInput = false
  69. LOOP UNTIL validInput
  70.  
  71. Display the month and the number of days it has
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement