Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ program. we are NOT aloud to use break, continue or goto. thank you. source/content/17/Lab_7.pdf 1 / 2 90% + CS 161 Programming Lab 7

c++ program. we are NOT aloud to use break, continue or goto. thank you. image text in transcribed
image text in transcribed
source/content/17/Lab_7.pdf 1 / 2 90% + CS 161 Programming Lab 7 Problem Description For this assignment, you are to compute the areas of four different geometric shapes: circle, square, rectangle, and triangle. For circle, square, and rectangle, you will also compute the perimeter. While this program requires the use of reference parameters, it will also be a review of functions, data validation, selection, and loops. Your functions should be split into function prototypes or declarations in a header file and function definitions in a code or source file. As part of the development process, you will need to write stubs for each of your functions to test that main works properly. The stubs should simply output their parameters. Note, in the final lab, the functions should not do any output, they should just do a calculation For this, as in all assignments, you are expected to follow the course programming style guidelines. Program Functionality In main, the user will be asked to enter a character to choose which shape they want, c for circle, s for square, r for rectangle, t for triangle, and e for end. Define constants for these characters. Display clear instructions to the user Input a character code for a shape, either upper or lower case Select the proper function based on the code o C-circle, get radius, call circle function, display area & circumference E-end program O R- rectangle, get length & width, call rectangle function, display area & perimeter S-square, get side, call square function, display area & perimeter T-triangle, get length & width, call triangle function display area o invalid input, output an error message Continue looping until the user has entered E for end Use floating point values for all numbers. Pl should be a constant equal to 3.14159. Required Functions At a minimum the program should have the following functions: getNumber o gets a valid positive floating-point number o returns the value O At a minimum the program should have the following functions: getNumber o gets a valid positive floating-point number o returns the value . circle o input is the radius o calculates area (PI*r*r) and circumference (2*PI*r) o passes back area and circumference via reference This work by Jim Bailey is licensed under a Creative Commons Attribution 4.0 International License . o rectangle input is length and width calculates the area (length*width) and perimeter(2 length+width)) passes back area and perimeter via reference square o input is length and width calculates the area (length*width) and perimeter(2*(length+width)) o passes back area and perimeter via reference O triangle o input is length and width o calculates the area (length*width/2) returns area via return The function getNumber is used to get all input numbers. Your main program will get all input and display all output. Make sure that all parameters and return values are the correct types

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

What is the growth rate of GDP per capita?

Answered: 1 week ago