I am trying to simplify the amount of loops inside of my pseudocode. Any feedbac
ID: 3791329 • Letter: I
Question
I am trying to simplify the amount of loops inside of my pseudocode. Any feedback or suggestions are greatly appreciated. If you could show me a way to build it with while statements that would be awesome. Thanks
FUNCTION zooMonitor ():
PROMPT// Ask user to enter one of three options
1. Monitor animals
2. Monitor habitats
3. Exit
A. IF zooMonitor = monitorAnimal
PRINT Which animal do you want to monitor?
B. IF zooMonitor = monitorHabitat
PRINT Which habitat do you want to monitor?
C. IF zooMonitor = Exit
END
END IF
WHILE zooMonitor = monitorAnimal
Select Animal
Lion
Gecko
Crocodile
Flamingo
ENDWHILE
// following the chosen animal
REPEAT // with user selected animal
PRINT “Animal: ”
PRINT “Daily Schedule: ”
PRINT “Assigned Keeper: ”
UNTIL condition
WHILE zooMonitor = monitorHabitat
Select Habitat
Penguin habitat
Wild kingdom
Bird habitat
Reptiles
ENDWHILE
//generates when habitat is selected
REPEAT // with user selected habitat
PRINT “Habitat”
PRINT “Cleanliness: ”
PRINT “Temperature: ”
UNTIL condition
// warning prompts for zookeeper concerning animal and habitat conditions
IF Habitat = Hazard
Print “Secure environment at once” // print new line
IF Temperature = threat
Print “Adjust at once” // print new line
IF Cleanliness = unhygienic
Print “Sterilize at once” // print new line
ELSE
ENDIF
RETURN
Explanation / Answer
I suggest you use switch case for selecting monitor animals or habitats. The inner while loops also could be replaced by switch statements.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.