Question: Use C++ please :) Objectives: Practice getting input from the user Practice using loops and conditions Practice using arrays Assignment: Create a program that asks

 Use C++ please :) Objectives: Practice getting input from the user

Practice using loops and conditions Practice using arrays Assignment: Create a program

Use C++ please :)

Objectives: Practice getting input from the user Practice using loops and conditions Practice using arrays Assignment: Create a program that asks the user for how many sides their shape has and tell them what their shape is based on that. There must be three possible options: 3 (triangle), 4 (quadrilateral), and 5 (pentagon). You should create a corresponding array based on the shape sides. Once the shape is determined, gather the length of all the sides and place them in the array. Once done, total the sides in a loop to determine the perimeter and display that information to the user. Details: Loop on side input -- check if there's a valid number of sides (3-5) o If there's not, display an error message and ask again Loop through the number of sides to build the array O ALSO . Check if the side length is valid (>0) Loop if it's not, asking again Loop until valid side length is entered Loop through completed array o This should be separate from the building array o Total the sides as you move through the array Once done, display to the user ** You can assume all input given will be the correct data type expected. Hints: Remember, a variable declared inside a loop/condition cannot be used outside of the structure. If you need to use it elsewhere, make sure you declare it before the structure and just initialize it inside of it. Example Execution: How many sides does your shape have? 6 That's not a valid shape here. Try again. How many sides does your shape have? 4 You have a quadrilateral! What is the length of side 1: 3 What is the length of side 2: 0 I'm sorry, that's not a valid length. Try again. What is the length of side 2: 4 What is the length of side 3: 3 What is the length of side 4: 4 Your perimeter is: 14

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!