summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/CST116-Lab2-Flowchart.txt
blob: 169fbf3e8b070d05b9e77262fb6d84ed9ca4af7e (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// OUTPUT //

Please enter a temperature between -80 to 121 degrees fahrenheit, or -62 and 49.5 degrees celsius.
Example entries: -32.3 F, 27.8 C

-32 Z

Invalid temperature system. Please try again with C or F as your unit.
-81 F

Temperature in fahrenheit must be between -80 and 121 degrees. Please try again.
122 F

Temperature in fahrenheit must be between -80 and 121 degrees. Please try again.
-63 C

Temperature in celsius must be between -62 and 49.5 degrees. Please try again.
50 C

Temperature in celsius must be between -62 and 49.5 degrees. Please try again.
32 F

Next, enter a wind speed between 0 and 231mph. You do not need to include a unit.
11.3

Conversions for 32F with wind speed 11.3MPH.

Celsius            Fahrenheit          Wind Speed          Wind Chill (F)      Wind Chill (C)
0.00                32.00               11.30               23.10               -4.95

// PSEUDOCODE //

DEFINE FUNCTION THAT RETURNS A FLOAT VALUE ConvertTemperature(float temperature, char temperatureSystem){

	IF temperatureSystem is C{

		RETURN (temperature * 1.8) + 32;

	} ELSE IF temperatureSystem is F{
	
		RETURN (temperature -32) / 1.8;

	}

}

DEFINE FUNCTION THAT RETURNS A BOOL VALUE CheckWindSpeed(reference float value){

	IF value IS LESS THAN 0 OR value IS GREATER THAN 231{
	
		print "Invalid wind speed. Please enter a number between 0 and 231";
		RETURN FALSE;

	}
	OTHERWISE RETURN TRUE;

}

DEFINE FUNCTION THAT RETURNS A FLOAT VALUE GetWindChill(){

	RETURN (35.74 + (0.6215 * temperatureFahrenheit) + (windSpeed^0.16 * (0.4275 * temperatureFahrenheit) - 35.75));

}

MAIN PROGRAM(){

	INITIALIZE CHAR choice TO BE 'Y'

	WHILE choice IS Y, DO THIS {


	PRINT "Please enter a temperature between -80 to 121 degrees fahrenheit, or -62 and 49.5 degrees celsius.";
	PRINT "Example entries: -32.3 F, 27.8 C";

	INITIALIZE FLOAT temperatureInput;
	INITIALIZE CHAR temperatureSystem;

	INITIALIZE BOOL validEntires AT false;

	DO AT LEAST ONCE{
	
		PUT INPUT INTO temperatureInput AND temperatureSystem;

		IF temperatureSystem IS 'C' {
		
			IF temperatureInput IS LESS THAN -62 OR temperatureInput IS GREATER THAN 49.5{
			
				PRINT "Temperature in celsius must be between -62 and 49.5 degrees. Please try again.";

			}OTHERWISE{
			
				SET validEntries TO true;
				SET temperatureCelsius TO temperatureInput;
				SET temperatureFahreneheit TO RETURN VALUE FROM ConvertTemperature WITH PARAMETERS temperatureINPUT and 'C';
			
			}
		}
		OTHERWISE IF temperatureSystem IS 'F' {
		
			IF temperatureInput IS LESS THAN -80 OR temperatureInput IS GREATER THAN 121{
			
				PRINT "Temperature in fahrenheit must be between -80 and 121 degrees. Please try again.";

			}OTHERWISE{
			
				SET validEntries TO true;
				SET temperatureFahrenheit TO temperatureInput;
				SET temperatureCelsius TO RETURN VALUE FROM ConvertTemperature WITH PARAMETERS temperatureINPUT and 'F';

		}


	}WHILE validEntries IS false;

	PRINT "Next, enter a wind speed between 0 and 231mph. You do not need to include a unit.";

	RESET validEntries BY SETTING IT TO false;

	DO AT LEAST ONCE {
	
		PUT INPUT INTO windSpeed;

		SET validEntries TO RETURN VALUE FROM CheckWindSpeed WITH PARAMETER windSpeed;

	}WHILE validEntires IS false;

	SET windChillFahrenheit TO RETURN VALUE FROM GetWindChill;
	SET windChillCelsius TO RETURN VALUE FROM ConvertTemperature WITH PARAMETERS windChillFahrenheit AND 'F';

	PRINT "Conversions for [TEMPERATURE INPUTTED BY USER] with wind speed [WIND SPEED ENTERED BY USER]MPH.";
	PRINT [FORMATTED TABLE WITH HEADERS FOR TEMPERATURE IN CELSIUS AND FAHRENHEIT, WIND SPEED, AND CALCULATED WIND CHILL];

	PRINT "If you would like to input another set of data, please enter 'Y'";

	SET choice TO INPUT;

	}

	END PROGRAM;

}