summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/cst116-lab2-wilson.cpp
blob: 03f08597efef3023fe53e96fa083358da1894929 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>      /* printf */
#include <math.h>       /* pow */
#include <cmath>        /* pow */


using namespace std;


using std::cout;
using std::cin;
using std::endl;


const float FMAX = 121; 
const float FMIN = -80;
const float CMAX = 49.5;
const float CMIN = -62; //Set values for minimum and maximum temperatures.


float CtoF(float Fahrenheit, float Celsius) { //float function so that it returns a float

    Fahrenheit = (Celsius * 9.0 / 5.0) + 32.0; //Converts Celsius to Fahrenheit

    return Fahrenheit; //Returns the newly defined fahrenheit to main
}





int main()
{
    float Celsius = 0.0; //Defines Celsius for the conversion function
    float Fahrenheit = 0.0; //Defines Fahrenheit for the conversion function
    float windspeed = 0.0;

    Loop: //Placeholder to loop back to

    cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n";
    cin >> Celsius; //Reads in Celsius from the user input

    if (Celsius <= CMAX && Celsius >= CMIN) {
        cout << "\t" << Celsius << " Degrees Celsius is approximately " << CtoF(Fahrenheit, Celsius) << " Degrees Fahrenheit\n\n";
    }
    else {
        goto Loop; //Goes back to placeholder to Loop in case of invalid response (past limits)
    }


    Loop2:

    cout << "Please enter the wind speed between 0 and 231 mph: ";
    cin >> windspeed;

    if (windspeed <= 231.0 && windspeed >= 0.0) {
        cout << "\n\tThe temperature is " << CtoF(Fahrenheit, Celsius) << " degrees Fahrenheit and the windspeed is " << windspeed << " mph." << endl;
    }
    else {
        goto Loop2; //Goes back to placeholder to Loop in case of invalid response (past limits)
    }

    

}