Question: CMPSC 201 -Spring 2019 Lab 6 To be done individually Due by end of your recitation section on 3/1/19. Goals: Practicing programmer-built functions, built-in functions,
CMPSC 201 -Spring 2019 Lab 6 To be done individually Due by end of your recitation section on 3/1/19. Goals: Practicing programmer-built functions, built-in functions, error checking and switches. Problem: Redo Labs 1-3 Makeup with some changes. Create a program that will calculate the area of an equilateral triangle, a square, or a circle based on the user's input and another shape of your choice (you should have 4 shapes total). The user should be prompted to enter a T for triangle, an S for square, C for circle, or a different letter for your shape. Use while loop to confirm the user has entered a correct character. The user should be able to enter either an upper or a lower case character. Your code should only contain lchar variable to store the users choice of shape. You should also prompt the user to enter the units which should be stored in a string object. You may assume the user enters valid units. Your code should contain a single programmer-built function that will be used to confirm the validity of the dimension the user enters. The function should accept to parameters: one parameter should be the numeric value for the dimension, and the other parameter should be a string specifying what the dimension is (such as "radius of circle", "side of triangle", etc.). The function body should contain a while loop which outputs a message to the user that the entered dimension is wrong and prompts the user to enter a new valuc. The message should be similar to The radius of the circle must be greater than 0." "Enter a numeric value greater than 0 for the radius of the circle." Your code should employ a switch structure to calculate the area for the shape entered. Inside the branch for the triangle, the user should be prompted to enter a value for the side of the triangle. Then call the programmer-built function to confirm that user's input is valid. Then calculate the area. Inside the branch for the square, the user should be prompted to enter a value for the side of the square. Then call the programmer-built function to confirm that user's input is valid. Then calculate the area. Inside the branch for the circle, the user should be prompted to enter a value for the radius of the circle. Then call the programmer-built function to confirm that user's input is valid. Then calculate the area. Write similar code for your new shape. Your code should call the programmer-built at least 4 times (it may be more depending on the shape you choose) Your output should contain the entered shape, the entered dimension plus the area and units similar to A square with a side of 2.5 inches has an area of 6.25 square inches." Make sure that your code follows the Assignment Guidelines posted on Canvas. Do not use any concepts beyond Chapter 6 in your textbook. Attach your C++ file to the Assignment on CANVAS. Remember to confirm all your submissions to CANVAS Lab 6 CMPSC 201-Spring 2019 CMPSC 201 - Spring 2019 Labs 1-3 makeup To be done individually Due by end of your recitation section on 2/8/19. Goals: Practicing variable definitions (declarations), built-in functions, error checking and switches. Problem: Create a program that will calculate the area of an equilateral triangle, square, or circle based on the user's input. The user should be prompted to enter a T for triangle, an S for square, or C for circle. Use a single-branch (simple) if or a while loop to confirm the user has entered a correct character. You may assume that the user entered an upper case character. You should also prompt the user to enter the units. Next use a switch structure to calculate the area for the shape entered. Inside the branch for the triangle, the user should be prompted to enter a value for the side of the triangle. Then use a use a single-branch (simple) if or a while loop to confirm the user has entered a valid value for the side of the triangle. Inside the branch for the square, the user should be prompted to enter a value for the side of the square. Then use a use a single-branch (simple) if or a while loop to confirm the user has entered a valid value for the side of the square. Inside the branch for the circle, the user should be prompted to enter a value for the radius of the circle. Then use a use a single-branch (simple) if or a while loop to confirm the user has entered a valid value for the radius of the circle. No "else" should appear in your code. Your output should contain the entered shape and dimension plus the area similar to "A square with a side of 2.5 inches has an area of 6.25 square inches." Make sure that your code follows the Assignment Guidelines posted on Canvas. Do not use any concepts beyond Chapter 5 in your textbook. Attach your C++ file to the Assignment on CANVAS. Remember to confirm all your submissions to CANVAS Labs 1-3 Makeup CMPSC 201-Spring 2019
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
