How would I write pseudocode for a program that will prompt a user to enter a bi
ID: 3766010 • Letter: H
Question
How would I write pseudocode for a program that will prompt a user to enter a birth month and day, and continue to prompt until the day entered is in range for the month? Compute the day's numeric position in the year (For example, February 2 is day 33). Use parallel arrays, find and display the traditional Zodiac sign for the date (Example Febrary 2 is Aquarius).
And do I have to design an application in which the number of days for each month in the year is stored in an array, assuming the year is not a leap year...first???
Explanation / Answer
Answer:
The pseudocode for the given birth month and day, printing the position of day in a year and zodiac sign.
Pseudocode:
start
Declarations
num day
num SIZE=12
num numdays
num total
num pos
string month
string zodiacSign
string MONTHS[SIZE] = "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
num Days[SIZE] = 31,28,31,30,31,30,31,31,30,31,30,31
num count = 0
num index =0
getData()
getPosition()
getZodiacSign()
finishUp()
stop
getData()
output "Enter name of month: "
input month
output "Enter day of the month: "
input day
while day<1 OR day > MONTHS[getIndex()]
output "Enter correct date. "
output "Enter day of the month: "
input day
endwhile
return
getIndex()
while month != MONTHS[count]
count = count + 1
endwhile
return
getPosition()
pos = count
index = 0
while index<=pos-1
total=total+MONTHS[index]
endwhile
total=total+day
return
getZodiacSign()
if (month == MONTH[0] AND day >= 21 AND day <= Days[0]) OR (month == MONTH[1] AND day >= 1 day <= 18)
zodiacSign = "Aquarius"
else
if (month == MONTH[1] AND day >= 19 AND day <= Days[1]) OR (month == MONTH[2] AND day >= 1 day <= 20)
zodiacSign = "Pisces"
else
if (month == MONTH[2] AND day >= 21 AND day <= Days[2]) OR (month == MONTH[3] AND day >= 1 day <= 19)
zodiacSign = "Aries"
else
if (month == MONTH[3] AND day >= 20 AND day <= Days[3]) OR (month == MONTH[4] AND day >= 1 day <= 20)
zodiacSign = "Taurus"
else
if (month == MONTH[4] AND day >= 21 AND day <= Days[4]) OR (month == MONTH[5] AND day >= 1 day <= 20)
zodiacSign = "Gemini"
else
if (month == MONTH[5] AND day >= 21 AND day <= Days[5]) OR (month == MONTH[6] AND day >= 1 day <= 22)
zodiacSign = "Cancer"
else
if (month == MONTH[6] AND day >= 23 AND day <= Days[6]) OR (month == MONTH[7] AND day >= 1 day <= 22)
zodiacSign = "Leo"
else
if (month == MONTH[7] AND day >= 23 AND day <= Days[7]) OR (month == MONTH[8] AND day >= 1 day <= 22)
zodiacSign = "Virgo"
else
if (month == MONTH[8] AND day >= 23 AND day <= Days[8]) OR (month == MONTH[9] AND day >= 1 day <= 22)
zodiacSign = "Libra"
else
if (month == MONTH[9] AND day >= 23 AND day <= Days[9]) OR (month == MONTH[10] AND day >= 1 day <= 22)
zodiacSign = "Scorpio"
else
if (month == MONTH[10] AND day >= 23 AND day <= Days[10]) OR (month == MONTH[11] AND day >= 1 day <= 21)
zodiacSign = "Sagittarius"
else
if (month == MONTH[11] AND day >= 22 AND day <= Days[11]) OR (month == MONTH[0] AND day >= 1 day <= 20)
zodiacSign = "Capricorn"
else
zodiacSign = "Illegal date"
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
return
finishUp()
output "Month - Day ", month, " - ",day
output "Numeric position of the day: ", total
output "Zodiac sign is: ", zodiacSign
return
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.