Difference: Lab3 (18 vs. 19)

Revision 192018-02-12 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Lab 3 - Functions

Line: 57 to 57
 

Sample output

Specifications

Changed:
<
<
  1. Use a switch statement to implement the menu for extra credit.

  2. Use functions for all subtasks (including printing the menu). Write comments and pre-and post conditions with function declarations. Tell what each function is supposed to be doing. Separate declarations from definitions. I suggest writing a void "User Interface" function for each menu selction, and then math oriented support functions that this calls.

>
>
  1. Use a switch statement to implement the menu.

  2. Use top down design for your system. Write functions for all subtasks (including printing the menu). For each user option (e.g. triangle size, hat size, temperature conversion) write a simple function that promopts the user for the required fields, then calls a computing function to get the result, then displays the results. For xample write a user interface function "void triangeUI()" to get the inputs, and display the results for the triangle. Then write another function "double triangle(double height, double width)" which is called by tranangleUI, that takes the values entered, does the computation, and then returns the results (in this case the area of the triangle). Write comments and pre-and post conditions with function declarations. Tell what each function is supposed to be doing. Separate declarations from definitions.

 
  1. Use the following formula to find the area of the triangle with sides a,b and c (project 13, Chp 5) Area= sqrt(s*(s-a)*(s-b)*(s-c)) where s = (a+b+c)/2. So, first ask for the lengths of the sides from the user. Not every 3 numbers can be sides of a triangle. They must satisfy the triangle inequality: The sum of any two sides must be greater than the third. You should check this condition and give an error message if it is not satisfied.

  2. All decimal point number outputs must have 2 digits after the decimal point.

  3. Overload the temperature conversion function to implement options 3 and 4. The function for option 3 takes an integer argument and returns an integer (which is the closest integer temperature). All computation is done with integers (no rounding needed). The other one will compute the exact value as a double. So both input and output types will be doubles. Thus you will need two celsius conversion functions, as seen below in the Overloaded Functions for Celsius section.

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback