Java homework:Need in 12 hours
CS 1043 Lab 7
Childress
Topics covered in this Lab: Nested Loops and Java IDE.
ADD A COMMENT AT THE TOP OF YOUR PROGRAM THAT STATES YOUR NAME,
YOUR LAB TIME, YOUR LAB INSTRUCTOR’S NAME, AND LAB6
Write a program that use a nested for-loop (for-loops in a for-loop) to create the following output
shape:
*********
*******
*****
***
*
***
*****
*******
*********
1. Your program should be generalized to ask the user to input the number of output-lines. The hourglass shape shown above has nine (9) output lines.
2. The input value provided by the user should always be a positive odd number or zero. Zero, an even number, or a negative number will cause the program to immediately exit.
3. Note that the number of lines is also equal to the number of output stars (asterisks) on the first and last lines.
4. Run your program for the input values –1, 1, 2, 7, 9, and 0 to demonstrate that it works properly.
5. The only print statements you are allowed to use are:
System.out.print( "Please enter an odd-number of
output-lines (enter zero to exit the program): " );
System.out.print('*'); // this is a single asterisk
System.out.print(' '); // this is a single blank
System.out.println(); // this is a new line