diff options
| author | tafaar <[email protected]> | 2022-11-08 18:39:42 -0800 |
|---|---|---|
| committer | tafaar <[email protected]> | 2022-11-08 18:39:42 -0800 |
| commit | e842037c1eed29cbe43ba8b60b690315f13f6152 (patch) | |
| tree | 4250f138827a4b24259e436fd7fbddf6b17c44ac /BlankConsoleLab/CST116-Lab2-Flowchart.txt | |
| parent | renamed solution (diff) | |
| download | cst116-lab2-hill-e842037c1eed29cbe43ba8b60b690315f13f6152.tar.xz cst116-lab2-hill-e842037c1eed29cbe43ba8b60b690315f13f6152.zip | |
added flowchart
Diffstat (limited to 'BlankConsoleLab/CST116-Lab2-Flowchart.txt')
| -rw-r--r-- | BlankConsoleLab/CST116-Lab2-Flowchart.txt | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/BlankConsoleLab/CST116-Lab2-Flowchart.txt b/BlankConsoleLab/CST116-Lab2-Flowchart.txt new file mode 100644 index 0000000..58171d1 --- /dev/null +++ b/BlankConsoleLab/CST116-Lab2-Flowchart.txt @@ -0,0 +1,132 @@ + +// 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(){ + + 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]; + + END PROGRAM; + +}
\ No newline at end of file |