summaryrefslogtreecommitdiff
path: root/CST116-Lab2-PseudoCode-Florea.txt
blob: 60b7370c55d2c76bded6e0c7c67495deaf9d0b8c (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
prototype func user_entry_temp
prototype func user_entry_speed
prototype func convert_to_f
prototype func calculate_wind_chill

initiate var F_MAX as const int, set it to 121
initiate var F_MIN as const int, set it to -80

initiate var C_MAX as const float, set it to 42.5
initiate var C_MIN as const int, set it to -62

initiate var W_MAX as const int, set it to 231
initiate var W_MIN as const int, set it to 0

def func int main
    initiate var temperature as float, set it to -100
    initiate var wind_speed as float, set it to -100
    initiate var chill as float
    initiate var temp_decision as char

    display "Do you want temp in Fahrenheit or Celsius?"
    take input for temp_decision
    call tolower on temp_decision

    call func user_entry_temp(pass temperature, pass temp_decision)
    call func user_entry_speed(pass wind_speed)

    call func calculate_wind_chill(pass temperature, pass wind_speed) set it to chill
    call func toupper on temp_decision

    display "For " + temperature + " degrees " + temp_decision + " and " + wind_speed + " mph"
    display " the wind chill is: " + chill


def func void user_entry_speed(float reference temperature, char decision)
    if decision is not equal to f or c
        while decision is not f and not C
            display "Wrong input for temp, do you want temp in F or C"
            take input for decision
            call func tolower on decision

    if decision is equal to c
        while temperature less than C_MIN and more than C_MAX
            display "Enter value for temp in Celsius"
            take input for temperature

        display "You entered " + temperature + " degrees celsius"
        call func convert_to_f and set return to temperature
    
    else if decision is equal to f
        while temperature is less than F_MIN or more than F_MAX
            display "Enter a value in Farnheit for temperature"
            take input for temperature
        
        display "You entered " + temperature + " degrees Fahrenheit"

def func void user_entry_speed(float reference wind_speed)
    while wind_speed is less than W_MIN or more than W_MAX
        display "Enter a speed for the wind"
        take input for wind_speed
    
    display "You entered " + wind_speed + " mph"

def func float convert_to_f(float c_temp)
    c_temp = 1.8 * c_temp + 32
    return c_temp

def func calculate_wind_chill(float temp, float wind)
    return 35.75 + .6215 * temp - 35.75 * wind^.16 + .4275 * temp * wind^.16