# Difference: Lab3 (1 vs. 20)

#### Revision 202018-02-20 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3 - Functions

Changed:
<
<

>
>

### Due: Feb 20, 11:55pm

Changed:
<
<
Moodle Link  >
>
Moodle Link  ### Turn in

• The code (as a cpp file),

#### Revision 192018-02-12 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3 - Functions

Line: 57 to 57

### 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.

#### Revision 182017-09-28 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3 - Functions

Line: 98 to 99
double waistSizeUnder28(double w); double celsius(double f); int celsius(int f);
Changed:
<
<
void prime(int number);
>
>
bool prime(int number);
double windChill(double temp, double wind_speed);

%ENDCODE%

#### Revision 172017-09-22 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3 - Functions

Changed:
<
<

>
>

### Due: Sept 28, 11:55pm

Changed:
<
<
Moodle Link  >
>
Moodle Link  ### Turn in

• The code (as a cpp file),

#### Revision 162017-02-20 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3 - Functions

Line: 61 to 60

1. 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.

2. 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.

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

Changed:
<
<
1. Overload the temperature conversion function to implement options 3 and 4. One for option 3 takes an integer argument and return an integer (which is the closest integer temperature). 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.

>
>
1. 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.

1. You should only accept positive inputs for option 5. Give an error message if the input is negative or 0. 1 is not prime by definition.

2. Use the following windchill computations from below:

#### Revision 152017-01-17 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"
Changed:
<
<

>
>

# Lab 3 - Functions

### Due: Feb 21, 11:55pm

Changed:
<
<
Moodle Link >
>
Moodle Link  ### Turn in

• The code (as a cpp file),
• A file with the collected outputs from the trial inputs below the run outputs as requested below.
Line: 146 to 148

 0 C Degrees, 12 m/sec
Solution
>
>
• Function.png:

 META FILEATTACHMENT attachment="Function.png" attr="" comment="" date="1484622291" name="Function.png" path="Function.png" size="3495" user="JimSkon" version="1"

 META TOPICMOVED by="JimSkon" date="1442949973" from="KenyonCpp.Lab4" to="KenyonCpp.Lab3"

#### Revision 142016-09-30 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 29, 11:55pm

Line: 31 to 31
If the lengths are acceptable, find and print the area of the triangle (according to the formula below, also see Project 13, Chp 5) If 2 Ask user's height,weight, and age
Changed:
<
<
Find and compute hat size, jacket size, waist according to formulas in Project 9, page 246 of the textbook
>
>
Find and compute hat size, jacket size, waist according to formulas in Project 9, page 243 of the textbook
If 3 Ask for the temperature in Fahrenheit, as an integer Compute the temperature in celsius to nearest integer and print it out
Line: 64 to 64

1. Use the following windchill computations from below:
###### Wind Chill Computations
>
>
This computations are done in Celsius and m/sec.
W = 13.12 + 0.6215 * t - 11.37 * v0.16 + 0.3965* t * v0.16

where

• v = wind speed in m/sec
• t = temperature in degrees Celsius: t <= 10
• W = windchill index (in degrees Celsius)
>
>
Optimally you should check if the temperature is not <= 10 and tell the user that the program cannot compute a wind chill above 10 degrees Celsius.

###### Functions

The idea is the break this project up into functional that are cohesive - e.g. each function has a singular purpose, and could (conceivably) be used again somewhere else. I came up with 2 types of functions, the user interface functions (UI) that "talk" to the user, and the support functions that provide (mostly mathematical) functional support for the UI functions.

#### Revision 132016-09-30 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 29, 11:55pm

Line: 63 to 64

1. Use the following windchill computations from below:
###### Wind Chill Computations
Changed:
<
<
W = 13.12 + 0.6215 * t - 11.37 * v0.16 + 0.3965* t * v0.016
>
>
W = 13.12 + 0.6215 * t - 11.37 * v0.16 + 0.3965* t * v0.16
where
• v = wind speed in m/sec
Line: 110 to 111
Turn in a run with all these inputs
Changed:
<
<
 Good clean, correct, easy to understand Input and output user interface 15 Complete source code with good formatting, variables names, and comments 15
>
>
 Code broken up in to functions, each of which performs a single objective. 20 Good clean, correct, easy to understand Input and output user interface 10 Complete source code with good formatting, variables names, and comments 10

 Area of a triangle correct solutions 10 Hat size, jacket size, waist solutions 10 Fahrenheit to Celsius (Integer) correct solutions 10

#### Revision 122016-09-29 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 29, 11:55pm

Line: 8 to 8

• The code (as a cpp file),
• A file with the collected outputs from the trial inputs below the run outputs as requested below.
• Follow the guidelines on Program Style described in section 2.5 of the textbook. ( See guidelines here)
Changed:
<
<

Feature %
Program correctness and completeness with respect to definition 70%
Code Format (Indenting, variable names, comments) 10%
Well Designed user interface (user prompts and outputs) 10%
Turning in complete run demonstrating each function at least twice with different values. 10%

>
>

### Problem

Write a C++ program which does the following (Below is an outline) (100 pts)
```repeat

```
Line: 25 to 18
3) Convert temperature from Fahrenheit to Celsius (nearest integers) 4) Convert temperature from Fahrenheit to Celsius (exact values) 5) Test a positive integer for being prime
Changed:
<
<
6) Calculate a windchill factor according to the formula in Programming Project 14 (page 300-1) of the textbook (though I am not convinced that it is the best formula available).
>
>
6) Calculate a windchill factor according to the formula from the text, given below.
7) Quit

Line: 59 to 52

Changed:
<
<
>
>

### 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.
3. 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.
4. All decimal point number outputs must have 2 digits after the decimal point.
5. Overload the temperature conversion function to implement options 3 and 4. One for option 3 takes an integer argument and return an integer (which is the closest integer temperature). The other one will compute the exact value as a double. So both input and output types will be doubles.
6. You should only accept positive inputs for option 5. Give an error message if the input is negative or 0. 1 is not prime by definition.
7. There is no universally accepted formula for the windchill factor. You may compare your answers against some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that calculate windchill effect:

### Wind Chill

>
>
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.

3. 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.

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

5. Overload the temperature conversion function to implement options 3 and 4. One for option 3 takes an integer argument and return an integer (which is the closest integer temperature). 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.

6. You should only accept positive inputs for option 5. Give an error message if the input is negative or 0. 1 is not prime by definition.

7. Use the following windchill computations from below:
###### Wind Chill Computations

W = 13.12 + 0.6215 * t - 11.37 * v0.16 + 0.3965* t * v0.016

where

• v = wind speed in m/sec
• t = temperature in degrees Celsius: t <= 10
• W = windchill index (in degrees Celsius)
###### Functions

The idea is the break this project up into functional that are cohesive - e.g. each function has a singular purpose, and could (conceivably) be used again somewhere else. I came up with 2 types of functions, the user interface functions (UI) that "talk" to the user, and the support functions that provide (mostly mathematical) functional support for the UI functions.

`<-- SyntaxHighlightingPlugin -->`
```// User Interface Functions
// Each option of the switch will simply call on of these.
void triangleUI();
void clothsUI();
void FtoCIntUI();
void FtoCDoubleUI();
void windchillUI();
void CheckPrimeUI();

//Support Functions
double triangleArea(double a, double b, double c);
double hatSize(double w, double h);
double jacketSizeUnder30(double w, double h);
double jacketSizeOver30(double w, double h, int age);
double waistSizeOver28(double w, int age);
double waistSizeUnder28(double w);
double celsius(double f);
int celsius(int f);
void prime(int number);
double windChill(double temp, double wind_speed);
```
`<-- end SyntaxHighlightingPlugin -->`

Recall that an overload function is one that uses the same name, but has differnent types. The C++ compiler calls the one that matches. You will need to implement each of the versions of `celsius` below. Which one gets called depends on the type in the call.

`<-- SyntaxHighlightingPlugin -->`
```double celsius(double f);
int celsius(int f);```
`<-- end SyntaxHighlightingPlugin -->`

Turn in a run with all these inputs

#### Revision 112016-09-28 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 29, 11:55pm

Line: 59 to 58
Until user quits
>
>

### Specifications

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.

#### Revision 102016-09-28 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 29, 11:55pm

Line: 67 to 67

1. Overload the temperature conversion function to implement options 3 and 4. One for option 3 takes an integer argument and return an integer (which is the closest integer temperature). The other one will compute the exact value as a double. So both input and output types will be doubles.
2. You should only accept positive inputs for option 5. Give an error message if the input is negative or 0. 1 is not prime by definition.
3. There is no universally accepted formula for the windchill factor. You may compare your answers against some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that calculate windchill effect:
>
>

### Wind Chill

Line: 98 to 103

 12557 13219 1
Changed:
<
<
 Wind Chill 22 Degrees, 34 MPH -6 Degrees, 64 MPH 0 Degrees, 12 MPH

### Wind Chill

>
>
 Wind Chill 22 C Degrees, 34 m/sec -6 C Degrees, 64 m/sec 0 C Degrees, 12 m/sec
Solution

#### Revision 92016-09-27 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 29, 11:55pm

Line: 68 to 68

1. You should only accept positive inputs for option 5. Give an error message if the input is negative or 0. 1 is not prime by definition.
2. There is no universally accepted formula for the windchill factor. You may compare your answers against some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that calculate windchill effect:
Changed:
<
<

### Test inputs

Turn in a run with all these inputs

Function Input
Area of a triangle 15, 20, 30
2.3, 7.75, 23.2
8, 0, 5
Hat size, jacket size, waist Height = 58, Weight = 167.5, Age = 32
Height = 42, Weight = 101.5, Age = 22
Height = 77, Weight = 255, Age = 55
Fahrenheit to Celsius (Integer) 32
-17
89
Fahrenheit to Celsius (Exact) 32
-17
89
Prime Check 2311
12557
13219
1
Temperature and wind speed 22 Degrees, 34 MPH
-6 Degrees, 64 MPH
0 Degrees, 12 MPH

>
>

Turn in a run with all these inputs
Line: 106 to 82

 Wind Chill solutions 10

### Test Input

Changed:
<
<
 Area of a triangle 10 15 20
>
>
 Area of a triangle 15, 20, 30

 2.3, 7.75, 23.2 8, 0, 5 Hat size, jacket size, waist Height = 58, Weight = 167.5, Age = 32

#### Revision 82016-09-20 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

Changed:
<
<

>
>

### Due: Sept 29, 11:55pm

Moodle Link ### Turn in

• The code (as a cpp file),

#### Revision 72016-09-06 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

Changed:
<
<

### Instructions

• Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
• Remember to format the code as described and the book and text, and to include comments including complete comment at the beginning of the program.
>
>
Moodle Link ### Turn in

• The code (as a cpp file),
• A file with the collected outputs from the trial inputs below the run outputs as requested below.
• Follow the guidelines on Program Style described in section 2.5 of the textbook. ( See guidelines here)

Feature %
Program correctness and completeness with respect to definition 70%
Changed:
<
<
 Code Format (Indenting, variable names) 10% Code Comments 10%
>
>
 Code Format (Indenting, variable names, comments) 10% Well Designed user interface (user prompts and outputs) 10%

 Turning in complete run demonstrating each function at least twice with different values. 10%

### Problem

Changed:
<
<
Write a C++ program which does the following (Below is an outline) (60 pts)
>
>
Write a C++ program which does the following (Below is an outline) (100 pts)

```repeat
1) Compute area of a triangle (according to the formula below)
2) Compute your clothing size (according to Project 9, in chapter 4 of the textbook)

```
Changed:
<
<
3) Convert temperature from Fahrenheit to Celcius (nearest integers) 4) Convert temperature from Fahrenheit to Celcius (exact values)
>
>
3) Convert temperature from Fahrenheit to Celsius (nearest integers) 4) Convert temperature from Fahrenheit to Celsius (exact values)
5) Test a positive integer for being prime 6) Calculate a windchill factor according to the formula in Programming Project 14 (page 300-1) of the textbook (though I am not convinced that it is the best formula available). 7) Quit
Line: 31 to 32
Test Option

If 1

Changed:
<
<
Ask the lengts of the sides of the triangle
>
>
Ask the lengths of the sides of the triangle
If the lengths are acceptable, find and print the area of the triangle (according to the formula below, also see Project 13, Chp 5) If 2 Ask user's height,weight, and age Find and compute hat size,jacket size, waist according to formulas in Project 9, page 246 of the textbook If 3 Ask for the temperature in Fahrenheit, as an integer
Changed:
<
<
Compute the temperature in celcius to nearest integer and print it out
>
>
Compute the temperature in celsius to nearest integer and print it out
If 4 Ask for the temperature in Fahrenheit (exact value)
Changed:
<
<
Compute the temperature in celcius (exact value) and print it out
>
>
Compute the temperature in celsius (exact value) and print it out
If 5 Ask for an integer and determine whether it is prime or not. If 6
Line: 57 to 58

### Specifications

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

1. 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.
Changed:
<
<
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.
>
>
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.

1. All decimal point number outputs must have 2 digits after the decimal point.
2. Overload the temperature conversion function to implement options 3 and 4. One for option 3 takes an integer argument and return an integer (which is the closest integer temperature). The other one will compute the exact value as a double. So both input and output types will be doubles.
Changed:
<
<
1. You should only accept `positive` inputs for option 5. Give an error message if the input is `negative` or `0. 1` is not prime by definition.
2. There is no universially accepted formula for the windchill factor. You may compare your answers againts some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that caculate windchill effect:
>
>
1. You should only accept positive inputs for option 5. Give an error message if the input is negative or 0. 1 is not prime by definition.
2. There is no universally accepted formula for the windchill factor. You may compare your answers against some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that calculate windchill effect:

### Test inputs

Turn in a run with all these inputs

Function Input
Area of a triangle 15, 20, 30
2.3, 7.75, 23.2
8, 0, 5
Hat size, jacket size, waist Height = 58, Weight = 167.5, Age = 32
Height = 42, Weight = 101.5, Age = 22
Height = 77, Weight = 255, Age = 55
Fahrenheit to Celsius (Integer) 32
-17
89
Fahrenheit to Celsius (Exact) 32
-17
89
Prime Check 2311
12557
13219
1
Temperature and wind speed 22 Degrees, 34 MPH
-6 Degrees, 64 MPH
0 Degrees, 12 MPH

Turn in a run with all these inputs

Good clean, correct, easy to understand Input and output user interface   15
Complete source code with good formatting, variables names, and comments   15
Area of a triangle correct solutions   10
Hat size, jacket size, waist solutions   10
Fahrenheit to Celsius (Integer) correct solutions   10
Fahrenheit to Celsius (Exact) correct solutions   10
Prime Check correct solutions   10
Wind Chill solutions   10

### Test Input

 Area of a triangle 10 15 20 2.3, 7.75, 23.2 8, 0, 5 Hat size, jacket size, waist Height = 58, Weight = 167.5, Age = 32 Height = 42, Weight = 101.5, Age = 22 Height = 77, Weight = 255, Age = 55 Fahrenheit to Celsius (Integer) 32 -17 89 Fahrenheit to Celsius (Exact) 32 -17 89 Prime Check 2311 12557 13219 1 Wind Chill 22 Degrees, 34 MPH -6 Degrees, 64 MPH 0 Degrees, 12 MPH

### Wind Chill

>
>
Solution

 META TOPICMOVED by="JimSkon" date="1442949973" from="KenyonCpp.Lab4" to="KenyonCpp.Lab3"

#### Revision 62016-09-04 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 27, 11:55pm

Line: 12 to 12

 Program correctness and completeness with respect to definition 70% Code Format (Indenting, variable names) 10% Code Comments 10%
Changed:
<
<
 Turning in complete run of every function at least twice with difference values. 10%
>
>
 Turning in complete run demonstrating each function at least twice with different values. 10%

### Problem

Write a C++ program which does the following (Below is an outline) (60 pts)

#### Revision 52016-08-24 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

Changed:
<
<

>
>

### Instructions

• Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
Changed:
<
<
• Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.
>
>
• Remember to format the code as described and the book and text, and to include comments including complete comment at the beginning of the program.

Feature %
Changed:
<
<
 Program correctness and completeness with respect to defination 70%
>
>
 Program correctness and completeness with respect to definition 70%

 Code Format (Indenting, variable names) 10% Code Comments 10% Turning in complete run of every function at least twice with difference values. 10%

#### Revision 42015-09-30 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

Changed:
<
<

>
>

### Instructions

• Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.

#### Revision 32015-09-29 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 29, 11:55pm

Line: 63 to 63

1. All decimal point number outputs must have 2 digits after the decimal point.
2. Overload the temperature conversion function to implement options 3 and 4. One for option 3 takes an integer argument and return an integer (which is the closest integer temperature). The other one will compute the exact value as a double. So both input and output types will be doubles.
3. You should only accept `positive` inputs for option 5. Give an error message if the input is `negative` or `0. 1` is not prime by definition.
Changed:
<
<
1. Make sure the restriction on the temperature is not violated. Use the "assert" Macro to achieve this (or better, use the alternative version we learned in class)
2. There is no universially accepted formula for the windchill factor. You may compare your answers againts some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that caculate windchill effect:
>
>
1. There is no universially accepted formula for the windchill factor. You may compare your answers againts some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that caculate windchill effect:

### Wind Chill

#### Revision 22015-09-22 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 3

### Due: Sept 29, 11:55pm

Line: 70 to 70

>
>
 META TOPICMOVED by="JimSkon" date="1442949973" from="KenyonCpp.Lab4" to="KenyonCpp.Lab3"

#### Revision 12015-09-20 - JimSkon

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

# Lab 3

### Instructions

• Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
• Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.

Feature %
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Turning in complete run of every function at least twice with difference values. 10%

### Problem

Write a C++ program which does the following (Below is an outline) (60 pts)

```repeat
1) Compute area of a triangle (according to the formula below)
2) Compute your clothing size (according to Project 9, in chapter 4 of the textbook)
3) Convert temperature from Fahrenheit to Celcius (nearest integers)
4) Convert temperature from Fahrenheit to Celcius (exact values)
5) Test a positive integer for being prime
6) Calculate a windchill factor according to the formula in Programming Project 14 (page 300-1) of the textbook (though I am not convinced that it is the best formula available).
7) Quit

Test Option

If  1
Ask the lengts of the sides of the triangle
If the lengths are acceptable, find and print the area of the triangle (according to the formula below, also see Project 13, Chp 5)
If  2
Find and compute hat size,jacket size, waist according to formulas in Project 9, page 246 of the textbook
If 3
Ask for the temperature in Fahrenheit, as an integer
Compute the temperature in celcius to nearest integer and print it out
If 4
Ask for the temperature in Fahrenheit (exact value)
Compute the temperature in celcius (exact value) and print it out
If  5
Ask for an integer and determine whether it is prime or not.
If 6
Ask for a temperature and wind speed to calculate windchill index
If 7
Quit the entire program
Otherwise
Print "Invalid option"

End Test

Until user quits
```

### Specifications

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.
3. 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.
4. All decimal point number outputs must have 2 digits after the decimal point.
5. Overload the temperature conversion function to implement options 3 and 4. One for option 3 takes an integer argument and return an integer (which is the closest integer temperature). The other one will compute the exact value as a double. So both input and output types will be doubles.
6. You should only accept `positive` inputs for option 5. Give an error message if the input is `negative` or `0. 1` is not prime by definition.
7. Make sure the restriction on the temperature is not violated. Use the "assert" Macro to achieve this (or better, use the alternative version we learned in class)
8. There is no universially accepted formula for the windchill factor. You may compare your answers againts some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that caculate windchill effect:

### Wind Chill

Copyright © 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