Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program to check whether a triangle is valid or not. A triangle is valid if and only if the sum of its

image text in transcribed

Write a C++ program to check whether a triangle is valid or not. A triangle is valid if and only if the sum of its three angles is 180. Your program should ask user to enter the values of the three angles and display if the triangle is valid or not. Further if the triangle is valid, your program should display its type. A triangle is an Equilateral Triangle, if all its angles are equal. A triangle is an Isosceles Triangle, if its two angles are equal A triangle is a Scalene Triangle, if none of its sides are equal. You have to use selection structures such as if else and/or nested if-else. See Sample runs of the program below: Sample Run 1 Enter 3 angles of the 140 40 20 Sample Run 2 Enter 3 angles of the triangle: 60 60 60 Sample Run 3 Enter 3 angles of the triangle: 45 45 90 You entered: angle 1 140 angle2-40 angle3-20 You entered: angle 1-60 angle2 60 angles 60 You entered: angle 1-45 angle2-45 angle3-90 Triangle is valid Equilateral triangle. Triangle is not valid Triangle is valid Isosceles triangle. Text in blue is values entered by user using keyboard. Text in black Sample Run 4 Enter 3 angles of the triangle:is displayed by your program. 40 60 80 You entered: angle 1-40 angle2 60 angle3-80 Triangle is valid Scalene triangle HINTS: if anglel, angle2 and angle3 are the 3 triangle angles. Triangle is valid if sum of the 3 angles is 180.Then the triangle is equilateral only if anglel is equal to angle2 and angle2 is equal to angle3. The triangle is isosceles if either anglel is equal to angle2 or anglel is equal to angle3 or angle2 is equal to angle3. The triangle is scalene if none of its angles are equal

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

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago