Question: Write a Java program that prints one of the following patterns based on the user choice of a pattern number, which must be between 1

Write a Java program that prints one of the following patterns based on the user choice of a pattern number, which must be between 1 and 4, or 5 to quit (See examples below), and an input value, which must be larger than 0 and smaller than 10, and according to the following: A) If the user enters any invalid pattern number, then the program should display a message indicating that input was invalid and request the user to either enters a correct pattern number or 5 to quit the entire program. That is, an entry of 5 would simply terminate the program. B) Once the pattern number is correctly supplied, the program requests the user to enter the input value. If the user enters any invalid value that is not within the expected range, then the program should reject this entry and asks the user to re-enter another value; this would repeat indefinitely until a good value is entered. C) Upon the entry of a good input value, the program must check whether this value is odd or even. If the user enters an odd number, then the program would draw a pattern that is similar to the following (i.e. the shown pattern is drawn if the user enters 5. You should notice that this is only an example; your program must allow for the general case for different appropriate values as indicated above.) You should notice that the patterns are actually quite similar whether the input is odd or even, with the exception of pattern # 4.

Write a Java program that prints one of the following patterns based

Example of output has to be like this:

on the user choice of a pattern number, which must be between

54321 5432 543 54 12345 2345 345 45 2 2 12 123 1234 12345 123 12345 123 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!