Starting from:

$25

IT1010 - Tutorial 9 - Introduction to Programming- Solved

Question 1   
Define a function called hypotenuse that calculates the length of the hypotenuse of a right triangle when the other two sides are given. The function should take two arguments of type double and return the hypotenuse as a double. In your main program write three assert statements to debug your function for the following scenarios.   

   

Triangle   
Side 1   
Side 2   
1   
3.0   
4.0   
2   
5.0   
12.0   
3   
8.0   
15.0   
   

Question 2   
Modify the above program to have another function called testHypotenuse() which contains the three assert statements you wrote. Call testHypotenuse() function in your main program.   

   

   

Additional Exercises    

   

Question 3   
Write a function qualityPoints that inputs a student’s average and return 4 it’s 90-100 , 3 if it’s 80-89 , 2 if it’s 70-79, 1 if it’s 60-69 , and 0 if the average is lower than 60.   

Write another function called testQualityPoints( ) which contains the assert statements to debug the above implemented function.   

  

More products