Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that asks the user to select a shape from a menu (1. Circle; 2. Triangle; 3. Rectangle;) and then calculates the area

image text in transcribed
image text in transcribed
image text in transcribed
Write a program that asks the user to select a shape from a menu (1. Circle; 2. Triangle; 3. Rectangle;) and then calculates the area of that shape using user inputs. Use a switch case structure to implement the menu. If the user tries to select an option that isn't on the menu or tries to enter negative values for the dimensions of the shape, print an appropriate error message, and keep asking for valid inputs. Use while to achieve this function. Create a function named as int positive checker(double num), taking an integer as the input and return whether the double number is positive or not. Use this function to test whether the users' inputs for the parameters of the shapes are invalid or not. Use 3.14 for pi. Name your program file Hw3 ql code.c. Example Hints and Inputs: (purple texts are what the program should print on the screen to instruct the users, the black texts are what the users type in) Select the shape you want to calculate the area of 1 Circle 2.Triang 3.Rectangle Illegal input! Please reinput! Please input the radius of the circle: -1 Illegal input! Please reinput Please input the radius of the circle: 1 Example Outputs: The area of the circle is: 3.140000 Example Hints and Inputs: (purple texts are what the program should print on the screen to instruct the users, the black texts are what the users type in)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions