Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

Communicate based on goals

Answered: 1 week ago

Question

2 The role of economic theory in economics.

Answered: 1 week ago