Question
Introduction In this project we use a while loop to print parts ofa well-known nursery rhyme. Humpty Dumpty sat on a wall, Humpty Dumpty had
Introduction
In this project we use a while loop to print parts ofa well-known nursery rhyme.
Humpty Dumpty sat on a wall,
Humpty Dumpty had a great fall.
All the king's horses and all the king's men
Couldn't put Humpty together again.
Specifications
- Write a program with a single while-loop that printsnumbers from 1 to an upper limit, each on their own line, butsubstituting parts of the rhyme for certain numbers as specifiedbelow.
- Ask the user for a single maximum count number, and no otherinput, prompting the user with these words: Enter max:
- When the loop count reaches a multiple of five print"Humpty" instead of the number.
Hint: put if-statements inside the braces of theloop.
- When the loop count reaches a multiple of seven print "Dumpty"instead of the number.
- For numbers which are multiples of bothfive and seven print "Had a Great Fall"instead of the number.
- Add a file comment block at the top of the code with a projectdescription, your name, pair-partner's name, and datecompleted.
- As with all projects, only use techniques we have covered sofar in the course and meet all academic integrity requirements ofthe syllabus.
Example: If the input is:
35
the output in a console or terminal is:
Enter max: 351234Humpty6Dumpty89Humpty111213DumptyHumpty16171819HumptyDumpty222324Humpty2627Dumpty29Humpty31323334Had a great fall
where the user enters the values shownin bold-italics (for emphasis)to produce the output. User input only appears if entered in aconsole or terminal and does NOT showin bold-italics.
Hints:
- Put several if-else statements inside the braces ofthe single for-loop.
- Test for numbers that are multiples of both7 and 5 first.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started