Introduction For this assignment, you are to create a program in Java that asks the user to enter the size of a shape (must be odd), then displays a menu of 4 options. Options 1-3 will print various shapes: closed square, open square, and diamond. Option 4 will allow the user to quit the program. You are to work on this assignment independently. Program Design You should have a single class called Shapes. You will have 5 static methods: main, printOpenSquare, printClosedSquare, printDiamond, and getShapeSize. The printOpenSquare, printClosedSquare, and printDiamond methods should take as input an int parameter called size and print the corresponding shape of the given size. (see sample output at the end) The getShapeSize method should ask the user to enter a number for the size of the shape. This number needs to be an ODD integer. If the user enters a number that is not odd, ask the user to reenter the number until it is odd. Then, the method should return that odd number. The main method should do the following: Enter a loop in which you will display a menu of choices (1-4) and wait for user input (see example at the end). The choices are: "1. Print closed square","2. Print open square","3. Print diamond", and "4. Quit program".If option 4 is selected, quit the program and print "Good bye!". Otherwise, ask the user to enter a number for the size of the shape by calling the getShapeSize method. Then, print the corresponding shape with dimensions = size x size, by calling the appropriate method. The exception is the diamond shape, which will have size rows and size+1 columns. See example for sample output. Additional Requirements The name of your Java Class that contains the main method should be Shapes. All your code should be within a single file. 2. Your code should follow good coding practices, including good use of whitespace (indents and line breaks) 1. and use of both inline and block comments. 3. You need to use meaningful identifier names that conform to standard Java naming conventions. 4. At the top of the file, you need to put in a block comment with the following information: your name, date, course name, semester, and assignment name. Your program needs to handle invalid inputs gracefully. For example, entering a number outside of a valid range should not crash the program. Instead, the user should be prompted to enter the number again. 6. The output of your program should exactly match the sample program output given at the end. 5. What to Turn In You will turn in the single Shapes.java file using BlackBoard. What You Need to Know for This Assignment Conditional statements Loops Getting user input Creating and calling methods
Introduction For this assignment, you are to create a program in Java that asks the user to enter the size of a shape (must be odd), then displays a menu of 4 options. Options 1-3 will print various shapes: closed square, open square, and diamond. Option 4 will allow the user to quit the program. You are to work on this assignment independently. Program Design You should have a single class called Shapes. You will have 5 static methods: main, printOpenSquare, printClosedSquare, printDiamond, and getShapeSize. The printOpenSquare, printClosedSquare, and printDiamond methods should take as input an int parameter called size and print the corresponding shape of the given size. (see sample output at the end) The getShapeSize method should ask the user to enter a number for the size of the shape. This number needs to be an ODD integer. If the user enters a number that is not odd, ask the user to reenter the number until it is odd. Then, the method should return that odd number. The main method should do the following: Enter a loop in which you will display a menu of choices (1-4) and wait for user input (see example at the end). The choices are: "1. Print closed square","2. Print open square","3. Print diamond", and "4. Quit program".If option 4 is selected, quit the program and print "Good bye!". Otherwise, ask the user to enter a number for the size of the shape by calling the getShapeSize method. Then, print the corresponding shape with dimensions = size x size, by calling the appropriate method. The exception is the diamond shape, which will have size rows and size+1 columns. See example for sample output. Additional Requirements The name of your Java Class that contains the main method should be Shapes. All your code should be within a single file. 2. Your code should follow good coding practices, including good use of whitespace (indents and line breaks) 1. and use of both inline and block comments. 3. You need to use meaningful identifier names that conform to standard Java naming conventions. 4. At the top of the file, you need to put in a block comment with the following information: your name, date, course name, semester, and assignment name. Your program needs to handle invalid inputs gracefully. For example, entering a number outside of a valid range should not crash the program. Instead, the user should be prompted to enter the number again. 6. The output of your program should exactly match the sample program output given at the end. 5. What to Turn In You will turn in the single Shapes.java file using BlackBoard. What You Need to Know for This Assignment Conditional statements Loops Getting user input Creating and calling methods
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 13PE
Related questions
Question
Use java.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 3 images
Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,