Title: Quiz #4
Author: Terry Weiss
Date: 10/14/15
Course & Section: CSC 111-003W
Description: This program prompts the User to enter a month and then displays how many days are in that month.
Initial Algorithm
Prompt for the month until given a valid input
Determine correct month and the correct name of the month
Display the name of the month in Title Case and the number of days in that month
Data Requirements:
Input:
(String) month – This is the month inputted by the User
Output:
(String) month – This is the month after it’s been formatted to the correct month name in Title Case
(String) days – This is the number of days in the month
Additional Variables:
(boolean) validInput – This notifies the loop as to whether valid input has been entered
Formulas:
N/A
Refined Algorithm
Initialize validInput = true
DO
Get the month in lower case {to have case insensitive input}
IF month == “1” OR month == “jan” OR month == “january” THEN
month = “January”
days = “31”
ELSE IF month == “2” OR month == “feb” OR month == “february” THEN
month = “February”
days = “28 or 29”
ELSE IF month == “3” OR month == “mar” OR month == “march” THEN
month = “March”
days = “31”
ELSE IF month == “4” OR month == “apr” OR month == “april” THEN
month = “April”
days = “30”
ELSE IF month == “5” OR month == “may” THEN
month = “May”
days = “31”
ELSE IF month == “6” OR month == “jun” OR month == “june” THEN
month = “June”
days = “30”
ELSE IF month == “7” OR month == “jul” OR month == “july” THEN
month = “July”
days = “31”
ELSE IF month == “8” OR month == “aug” OR month == “august” THEN
month = “August”
days = “31”
ELSE IF month == “9” OR month == “sept” OR month == “september” THEN
month = “September”
days = “30”
ELSE IF month == “10” OR month == “oct” OR month == “october” THEN
month = “October”
days = “31”
ELSE IF month == “11” OR month == “nov” OR month == “november” THEN
month = “November”
days = “30”
ELSE IF month == “12” OR month == “dec” OR month == “december” THEN
month = “December”
days = “31”
ELSE
Display error about invalid month being entered
validInput = false
LOOP UNTIL validInput
Display the month and the number of days it has
Comments