Question
Problem B: Triangle-tastic (20 points) Say you want to enter a number of triangles and want to find the average area of them all. You
Problem B: Triangle-tastic (20 points) Say you want to enter a number of triangles and want to find the average area of them all. You input a triangle by typing t then entering the base and height of the triangle. When you are done, type q to quit. The program should then display the average area for all triangles entered. The area of a triangle for base b and height h is Area = 1 2 bh Your program is expected to handle a few specific special / error cases:
IF the user enters no valid triangles before quitting, rather than crashing, or displaying an average area of 0, say No triangles.
If the user enters a command other than t (for triangle) or q (for quit) display an error message: Unknown command, try again, and repeat.
If the user enters a triangle with non-positive (0 or negative) base or hieght, just like the other case, print an error messsage Invalid triangle, try again and contune without counting this triangle.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started