summaryrefslogtreecommitdiff
path: root/CST116-Lab2-Davis-PSEUDOCODE.rtf
blob: e7c1fb4c199ebde5c8b564139c5a9aad8f819596 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
{\rtf1\ansi\ansicpg1252\cocoartf2639
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Menlo-Regular;\f2\fnil\fcharset0 Menlo-Bold;
}
{\colortbl;\red255\green255\blue255;\red252\green106\blue93;\red31\green31\blue36;\red230\green255\blue218;
\red255\green255\blue255;\red252\green95\blue163;\red208\green191\blue105;\red108\green121\blue134;\red103\green183\blue164;
}
{\*\expandedcolortbl;;\csgenericrgb\c98912\c41558\c36568;\csgenericrgb\c12054\c12284\c14131;\cspthree\c93335\c100000\c89365;
\csgenericrgb\c100000\c100000\c100000\c85000;\csgenericrgb\c98839\c37355\c63833;\csgenericrgb\c81498\c74939\c41233;\csgenericrgb\c42394\c47462\c52518;\csgenericrgb\c40538\c71705\c64209;
}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs24 \cf0 Lab 2 Pseudo-code\
\
declares use of cout cin and endl\
\
after main run getdata then printdata\
\
const int Cmax = 49.5 Cmin = -62 Fmax = 121 Fmin = -80\
\
int main\
\{\
variables temp, choice, windspeed, and windchill = 0\
\
run getdata then print data\
\
return nothing to main;\
\}\
int getdata\
\{\

\f1 \cf2 \cb3    \cf4 print\cf2  "Hello!"\cf5 \
\pard\tx593\pardeftab593\pardirnatural\partightenfactor0
\cf5 \cb3    print \cf2 "Will you be using Celsius or Fahrenheit? Please enter a '1' for Celsius and '2' for Fahrenheit"\cf5 \
   user input = choice;\
    
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (choice == \cf7 \cb3 1\cf5 \cb3 ) \cf8 \cb3 //finding if the user wants C or F\cf5 \cb3 \
    \{\
       print \cf2 "What is the temperature? Please enter a value between "\cf5 <<\cf9 \cb3 CMIN\cf5 \cb3 <<\cf2 " and "\cf5 <<\cf9 \cb3 CMAX\cf5 \cb3 <<\
       user input = temperature; \cf8 \cb3 //getting temp off of C\cf5 \cb3 \
        
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (temperature < \cf9 \cb3 CMIN\cf5 \cb3 )\
        \{\
           print \cf2 "Please enter a larger number"\cf5 \
           user input = temperature;\
        \}\
        
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3  
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (temperature >\cf9 \cb3 CMAX\cf5 \cb3 )\
        \{\
           print \cf2 "Please enter a smaller number"\cf5 \
           user input = temperature;\
        \}\
        
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3 \
        \{\
            temperature = ((\cf7 \cb3 9\cf5 \cb3 /\cf7 \cb3 5\cf5 \cb3 ) * temperature + \cf7 \cb3 32\cf5 \cb3 );\
        \}\
    \}\
    
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3  
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (choice == \cf7 \cb3 2\cf5 \cb3 )\
    \{\
       print \cf2 "What is the temperature? Please enter a value between "\cf5 <<\cf9 \cb3 FMIN\cf5 \cb3 <<\cf2 " and "\cf5 <<\cf9 \cb3 FMAX\cf5 \cb3 <<\
       user input = temperature; \cf8 \cb3 //getting temp off of F\cf5 \cb3 \
        
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (temperature < \cf9 \cb3 FMIN\cf5 \cb3 )\
        \{\
           print \cf2 "Please enter a larger number"\cf5 \
           user input = temperature;\
        \}\
        
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3  
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (temperature > \cf9 \cb3 FMAX\cf5 \cb3 )\
        \{\
           print \cf2 "Please enter a smaller number"\cf5 \
           user input = temperature;\
        \}\
        
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3 \
        \{\
           print \cf2 "Perfect!"\cf5 \
        \}\
    \}\
    
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3  
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (choice > \cf7 \cb3 2\cf5 \cb3  or choice < \cf7 \cb3 1\cf5 \cb3 )\
    \{\
        
\f2\b \cf6 \cb3 do
\f1\b0 \cf5 \cb3 \
        \{\
           print \cf2 "Please enter 1 or 2"\cf5 \
                user input = choice;\
        \}\
        
\f2\b \cf6 \cb3 while
\f1\b0 \cf5 \cb3  (choice > \cf7 \cb3 2\cf5 \cb3  || choice < \cf7 \cb3 1\cf5 \cb3 );\
        
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (choice == \cf7 \cb3 1\cf5 \cb3 ) \cf8 \cb3 //finding if the user wants C or F\cf5 \cb3 \
        \{\
           print \cf2 "What is the temperature? Please enter a value between "\cf5 <<\cf9 \cb3 CMIN\cf5 \cb3 <<\cf2 " and "\cf5 <<\cf9 \cb3 CMAX\cf5 \cb3 <<\
           user input =  temperature; \cf8 \cb3 //getting temp off of C\cf5 \cb3 \
            
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (temperature < \cf9 \cb3 CMIN\cf5 \cb3 )\
            \{\
               print \cf2 "Please enter a larger number"\cf5 \
               user input = temperature\
            \}\
            
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3  
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (temperature > \cf9 \cb3 CMAX\cf5 \cb3 )\
            \{\
              print \cf2 "Please enter a smaller number"\cf5 \
              user input = temperature;\
            \}\
            
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3 \
            \{\
                temperature = ((\cf7 \cb3 9\cf5 \cb3 /\cf7 \cb3 5\cf5 \cb3 ) * temperature + \cf7 \cb3 32\cf5 \cb3 );\
            \}\
        \}\
        
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3  
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (choice == \cf7 \cb3 2\cf5 \cb3 )\
        \{\
           print \cf2 "What is the temperature? Please enter a value between "\cf5 <<\cf9 \cb3 FMIN\cf5 \cb3 <<\cf2 " and "\cf5 <<\cf9 \cb3 FMAX\cf5 \cb3 <<\
            user input = temperature; \cf8 \cb3 //getting temp off of F\cf5 \cb3 \
            
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (temperature < \cf9 \cb3 FMIN\cf5 \cb3 )\
            \{\
              print \cf2 "Please enter a larger number"\cf5 \
              user input = temperature;\
            \}\
            
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3  
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (temperature > \cf9 \cb3 FMAX\cf5 \cb3 )\
            \{\
               print \cf2 "Please enter a smaller number"\cf5 \
               user input = temperature;\
            \}\
            
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3 \
            \{\
               print \cf2 "Perfect!"\cf5 \
            \}\
        \}\
    \}\
    
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3 \
    \{\
       print \cf2 "uhhhh something went wrong"\cf5 \
    \}\
   print \cf2 "Now what is the windspeed in MPH? Please enter a value less than 231 and greater than 0"\cf8 \cb3 //finding windspeed\cf5 \cb3 \
   user input = windspeed;\
    
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (windspeed > \cf7 \cb3 231\cf5 \cb3 )\
    \{\
       print \cf2 "Please enter a smaller value"\cf5 \
       user input = windspeed;\
    \}\
    
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3  
\f2\b \cf6 \cb3 if
\f1\b0 \cf5 \cb3  (windspeed < \cf7 \cb3 0\cf5 \cb3 )\
    \{\
       print \cf2 "please enter a larger number"\cf5 \
       user input = windspeed;\
    \}\
    
\f2\b \cf6 \cb3 else
\f1\b0 \cf5 \cb3 \
    \{\
        windchill = (\cf7 \cb3 35.74\cf5 \cb3  + \cf7 \cb3 0.6215\cf5 \cb3  * (temperature) - \cf7 \cb3 35.75\cf5 \cb3  * ((windspeed)^\cf7 \cb3 16\cf5 \cb3 ) + \cf7 \cb3 0.4275\cf5 \cb3  * (temperature) * ((windspeed)^\cf7 \cb3 16\cf5 \cb3 )); \cf8 \cb3 //getting windchill\cf5 \cb3 \
    \}
\f0 \cf0 \cb1 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
return choice, temperature, windspeed, and windchill to main\
\}\
void printdata\
\{\
if choice == 1\
 \{\
   print 
\f1 \cf2 \cb3 "You chose to input your temperature in Celsius. The program has convertered the temp into Fahrenheit and the temperature is "\cf5 <<temperature<<
\f0 \cf0 \cb1 \
\}\
else if choice == 2\
\{\
print 
\f1 \cf2 \cb3 "You chose to input your temperature in Fahrenheit. You input "\cf5 <<temperature<<
\f0 \cf0 \cb1 \
\}\
else \
\{\
print 
\f1 \cf2 \cb3 "Something went wrong..."\

\f0 \cf0 \cb1 \} \
print 
\f1 \cf2 \cb3 "You put "\cf5 <<windspeed<<\cf2 " for your windspeed"\cf5 \
\pard\tx593\pardeftab593\pardirnatural\partightenfactor0
\cf5 \cb3 print \cf2 "Based off your temperature and windspeed, the windchill is "\cf5 <<windchill<<
\f0 \cf0 \cb1 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \}}