Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that prints an oval using the character *. The user will enter the number of *s on the middle row and then

Write a program that prints an oval using the character *. The user will enter the number of *s on the middle row and then the number of rows above and below the middle row. For instance, an oval with 16 *s in the middle row and 2 rows above and below looks like:

 ************ ************** **************** ************** ************ 

No row is allowed to have less than two *s. You will write code to check for this.

Prompt and read in the number of *s in the middle row;

(b) If the number of *s is less than three, print the error message Size of the middle row must be at least three., and prompt again for the number of *s in the middle row. Repeat until the user enters a valid number. (Use a while loop.)

(c) Prompt and read in the number of rows above and below the middle row.

(d) If the number of rows is invalid then print Invalid number of rows. and prompt again for the number rows. An invalid number of rows would be a negative number or a number that leads to a row in the oval with less than two *s. Repeat until the user enters a valid number of rows. (Use a while loop.)

(e) Display an empty line.

(f) Use for loops to display the oval. Your outer for loop will iterate over the number of rows times. For each row use one nested for loop to display blanks (the middle row contains no blanks) and another nested for loop to display the characters *.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

3. Is it a topic that your audience will find worthwhile?

Answered: 1 week ago

Question

2. Does the topic meet the criteria specified in the assignment?

Answered: 1 week ago