COP3014-Foundations of Computer Science Assignment #4

$30.00

Category: Tags: , , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (4 votes)

Objectives:
1. Be able to use the call-by-value mechanism
2. Be able to use the call-by-reference mechanism
Write a program called β€œall_area_semi.cpp” that computes the area of an arbitrary
triangle. Use the following formula:
π‘Žπ‘Ÿπ‘’π‘Ž = βˆšπ‘ (𝑠 βˆ’ π‘Ž)(𝑠 βˆ’ 𝑏)(𝑠 βˆ’ 𝑐)
where a, b and c are the lengths of the sides, and s is the semiperimeter.
s = (a + b + c) / 2
Include a void function call β€œCompute” that computes the area and perimeter of a
triangle based on the length of the sides. The function should use five parameters –
three call by value parameters (a, b, c) that provide the lengths of the edges and
two call by reference parameters (area, semiperimeter) that stores the computed
area and perimeter. Make your function robust. The function β€œCompute” should
be called from your main program. Your must print the computed area and
semiperimeter rounded to the nearest hundredths. In main you should declared the
necessary variables, and include a while loop asking the user if he/she would like
to continue computing area and semiperimeters.
Note that not all combinations of a, b, and c produce a triangle. Remember, the
sum of any two sides of a triangle must be greater than the third side. You must
make sure that the lengths of the sides of the triangle entered by the user are valid;
if not valid lengths, you should let the user know by printing a message stating that
the lengths are invalid, and then prompt the user if he/she would like to continue
computing area and semiperimeters.Your function should produce correct results
for legal data and reasonable results for illegal combinations.
You may implement more functions if you find it necessary. Please start the
assignment ASAP and ask questions to make sure you understand what you
must do. Remember to follow all style rules and to include all necessary
documentation (consistent, indentation, proper variable names, pre/post
condition, program header, function headers, and so forth.)
Electronically submit the source file ” all_area_semi.cpp ” in the Assignments
area of blackboard before the due date and time. Remember, submit your
assignment on time no matter if it is incomplete and/or incorrect.
Consider the following skeleton as a hint:
//include necessary libraries
using namespace std;
//include function prototypes
//void Compute(format parameters go here)
//{
//}
int main( )
{
//declare variables a, b, c,area, and semiperimeter
//declare variable for while loop
//while loop
//begin while loop
//call Computer
//end while loop
return 0;
}