Question: in java This program will prompt the user for a shape to draw, prompt the user for information about that shape, and then draw the


This program will prompt the user for a "shape" to draw, prompt the user for information about that shape, and then draw the shape to the screen. We will utilize the concepts of loops, conditionals, parameter passing to functions, and user input. Objective Using "if statements" to perform a desired user action (based upon user input) and to perform simple "input validation". NOTE: For now, we are NOT "re-prompting" the user for any erroneous input, the program will just simply display a message and end. Requirements: Your program should have: 1. A function which prompts the user for the type of shape to draw, either: rectangle triangle 2. A function which prompts the user for the numeric values: . The dimensions of the shape. 3. If the user selects triangle: Prompt the user for the height of the triangle. Draw a filled Triangle (See below). 4. If the user selects rectangle: . Prompt the user for the height and width of the rectangle. Draw a "hollow" rectangle (see below). 5. If the user makes a choice which cannot be fulfilled, then the program should display a simple, but meaningful error message and terminate. 6. Add more meaningful comments to the functions to indicate the parameters which they accept and the values which are returned. Below are several sample runs of the program: Sample 1: Enter the type of shape (rectangle, triangle): circle Sorry, I don't know how to draw a circle Sample 2: Enter the type of shape (rectangle, triangle): rectangle Enter the height of your Rectangle: -5 Sorry, I don't know how to draw a rectangle with negative values. Sample 3: Enter the type of shape (rectangle, t riangle): rectangle Enter the height of your Rectangle: 5 Enter the width of your Rectangle: 10 Sample 4: Please the type of shape (rectangle, triangle): triangle Please enter the height of your Trian gle: 8 *** ***** ******* ******* **
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
