Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program to analyze a variety of triangles. The program should determine all angles and all sides for a triangle for three different

Write a C++ program to analyze a variety of triangles. The program should determine all angles and all sides for a triangle for three different options (give the user a menu of choices):

  1. Given two sides and the angle between
  2. Given two angles and one side
  3. Given three sides

Option 1: Given two sides and the angle between

First check to be sure that the three values entered are valid. In particular, the following conditions must be met:

  • Both sides > 0
  • If angle is in degrees, then 0 < angle < 180 (if angle is in radians, convert it to degrees first and then check)

Option 2: Given two angles and one side

First check to be sure that the three values entered are valid. In particular, the following conditions must be met:

  • Side > 0
  • For each angle: 0 < angle < 180 (if angle is in radians, convert it to degrees first and then check)
  • For the sum of the two angles entered: 0 < Sum < 180 (if angles are in radians, convert them to degrees first and then check)

Other program requirements:

  • The user should be able to indicate whether and angle is being entered is in degrees or in radians by entering either d or D for degrees or entering r or R for radians. Examples:
    • Please enter the angle: 30 d
    • Please enter the angle: 30 D
    • Please enter the angle: 1.5 r
    • Please enter the angle: 1.5 R
  • If any bad inputs are entered, print out an appropriate error message and terminate the program using the command: return 1;

Bad inputs include invalid triangles, invalid menu choices, and invalid units for angles.

  • Example:

if (Side < 0)

{ cout << Error. Negative value for side not allowed. Program terminated.;

Return 1;

}

  • After performing the calculations for any of the three menu choices, display the values for all three sides and all three angles (in degrees).
    • Use 2 digits after the decimal pint for all angles.
    • Use 3 digits after the decimal pint for all sides.
    • Include the unit degrees after all angles.
    • N units are required for the sides.
  • Note that for option 2, the calculations are different based on which side is entered. Ask the user to enter angles A and B, and then ask the user which side that they would like to enter (a, b, or c). Perform the appropriate calculations in each case.
  • Run the program for the following 7 test cases:
    • Optin 1: a = 20, b = 15, C = 35
    • Optin 1: a = 20, b = 15, C = 0.5 radians
    • Optin 2: A = 30, B = 100, and a = 20
    • Optin 2: A = 30, B = 100, and b = 20\
    • Optin 2: A = 30, B = 100, and c = 20
    • Optin 3: a = 20, b = 15, c = 10\
    • Optin 3: a = 5, b = 12, c = 13

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

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

Which comes first: migration, synaptogenesis, or myelination?

Answered: 1 week ago