Question: Write a complete Java program that reads an odd number from the user. Your program should then use this odd number and nested for

Write a complete Java program that reads an odd number from the

 

Write a complete Java program that reads an odd number from the user. Your program should then use this odd number and nested for loops to print a cross made of stars. Some samples of how your program should run are shown below (user input in bold): Please enter an odd number of stars: 3 * * * * * Please enter an odd number of stars: 5 * * * * Hint: The trick is to realize that there are two cases in which you have to place a star: 1. When the row and column numbers are the same (i.e., when row = 0 and column = 0 there is a star. Same when row = 1 and column=1, etc.) 2. When the row number and the column numbers are opposites. (ex. if the user entered 7 stars, then there is a star drawn when row = 0 and column = 6, when row = 1 and column 5, etc...) Activate 3. You can also use the method you learned in the class to print the pattern. Consider the etting upper half, the middle row and the lower half separately.

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 Programming Questions!