LAB 03B - TRIANGLE CLASSIFIER + OPTION MENU

Concepts

The goal of this lab is to practice the use of the switch statement. Your solution will be submitted with HW 03 next Wednesday.

Let's Start

For this lab, we are providing you with some initial code. First create yourself an empty project, and then add a new C++ source file called main.cpp. In your main.cpp, copy/paste the code that is available here.

Instructions

In Lab 03A you created a program that classifies triangles based on three side measurements provided by the user. For Lab 03B, you need to offer to the user the following menu of options:

1. Enter measurements
2. Print measurements
3. Check triangle feasibility
4. Classify triangle
5. Exit

The initial code provided in the Lab 03B main.cpp file does several tasks for you: (1) reads the user's choice, (2) verifies that the chosen option is a number between 1 and 5, and (3) quits the execution of the program if the user chooses option 5 (exit). The initial code provided also includes a do-while loop, which is a C++ repetition statement that we will cover next week; just leave this code alone for now. Your task is to add code to this initial program that implements each of these menu options, which are explained in more detail below. NOTE: a good chunk of the code you wrote for Lab 03A is useful for this lab; feel free to cut/paste what you have already written (if useful).

Option 1: Enter Measurements

Ask the user to enter three real value measurements (i.e., > 0). Read these measurements using the already declared variables named inputA, inputB, and inputC. If any of the measurements provided by the user is invalid (i.e., <= 0), then print an error message and immediately quit the entire program (return 0). If all three measurements are valid, copy the variables to the already declared variables named a, b, and c, such that c is the largest. Once done, set the boolean variable isTriangle to false, as you have yet to test whether the measurements provided form a triangle.

Option 2: Print Measurements

In this option, you should print the measurements (i.e., variables a, b, and c).

Option 3: Check Triangle Feasibility

For this option, you should check whether the input provided forms a triangle. Depending on your calculation, you should set the boolean variable isTriangle to be true or false.

Option 4: Classify Triangle

You should classify a triangle IF (and only if) a triangle exists (i.e., isTriangle is true). If this boolean variable is true, tell the user whether the triangle is a right, acute, or obtuse triangle.

Option 5: Exit

Duh - exit!

Program Use

A smart user of this program will first choose Option 1 (to enter measurements), then Option 2 (to verify measurements entered are correct), then Option 3 (to check whether the measurements form a triangle), and then Option 4 (to classify the triangle). Unlike the real world, you can assume only smart users of your program exist.

Lab Submission

You will submit your solution to this lab with your third homework assignment. Detailed instructions for doing this are posted in Homework 03.