From d82e1b71f7d003eead5d5350aaf7da41b142ae15 Mon Sep 17 00:00:00 2001 From: levidavis04 <114828884+levidavis04@users.noreply.github.com> Date: Mon, 14 Nov 2022 15:41:02 -0800 Subject: Add files via upload --- CST116-Lab2-Davis-PSEUDOCODE.rtf | 234 +++++++++++++++++++++++++++++++++++++++ CST116-Lab2-Davis.cpp | 163 +++++++++++++++++++++++++++ 2 files changed, 397 insertions(+) create mode 100644 CST116-Lab2-Davis-PSEUDOCODE.rtf create mode 100644 CST116-Lab2-Davis.cpp diff --git a/CST116-Lab2-Davis-PSEUDOCODE.rtf b/CST116-Lab2-Davis-PSEUDOCODE.rtf new file mode 100644 index 0000000..e7c1fb4 --- /dev/null +++ b/CST116-Lab2-Davis-PSEUDOCODE.rtf @@ -0,0 +1,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 < + +using std::cout; +using std::cin; +using std::endl; + +const int FMIN = -80; +const int FMAX = 121; +const int CMIN = -62; +const float CMAX = 49.5; + +int getdata (int (choice), float (temperature), float (windchill), int (windspeed)); +void printdata(float (temperature), float (windchill), int (windspeed), int (chocie)); + +int main() +{ + float temperature = 0.0; + int choice = 0; + int windspeed = 0; + float windchill = 0.0; + + getdata(int (choice), float (temperature), float (windchill), int (windspeed)); + printdata(float (temperature), float (windchill), int (windspeed), int (choice)); + return 0; +} +int getdata(int (choice), float (temperature), float (windchill), int (windspeed)) +{ + cout <<"Hello!"<< endl; + cout <<"Will you be using Celsius or Fahrenheit? Please enter a '1' for Celsius and '2' for Fahrenheit"<> choice; + if (choice == 1) //finding if the user wants C or F + { + cout << "What is the temperature? Please enter a value between "<> temperature; //getting temp off of C + if (temperature < CMIN) + { + cout <<"Please enter a larger number"<> temperature; + } + else if (temperature >CMAX) + { + cout << "Please enter a smaller number"<> temperature; + } + else + { + temperature = ((9/5) * temperature + 32); + } + } + else if (choice == 2) + { + cout << "What is the temperature? Please enter a value between "<> temperature; //getting temp off of F + if (temperature < FMIN) + { + cout <<"Please enter a larger number"<> temperature; + } + else if (temperature > FMAX) + { + cout << "Please enter a smaller number"<> temperature; + } + else + { + cout << "Perfect!"< 2 || choice < 1) + { + do + { + cout << "Please enter 1 or 2"<> choice; + } + while (choice > 2 || choice < 1); + if (choice == 1) //finding if the user wants C or F + { + cout << "What is the temperature? Please enter a value between "<> temperature; //getting temp off of C + if (temperature < CMIN) + { + cout <<"Please enter a larger number"<> temperature; + } + else if (temperature > CMAX) + { + cout << "Please enter a smaller number"<> temperature; + } + else + { + temperature = ((9/5) * temperature + 32); + } + } + else if (choice == 2) + { + cout << "What is the temperature? Please enter a value between "<> temperature; //getting temp off of F + if (temperature < FMIN) + { + cout <<"Please enter a larger number"<> temperature; + } + else if (temperature > FMAX) + { + cout << "Please enter a smaller number"<> temperature; + } + else + { + cout << "Perfect!"<> windspeed; + if (windspeed > 231) + { + cout << "Please enter a smaller value"<> windspeed; + } + else if (windspeed < 0) + { + cout <<"please enter a larger number"<> windspeed; + } + else + { + windchill = (35.74 + 0.6215 * (temperature) - 35.75 * ((windspeed)^16) + 0.4275 * (temperature) * ((windspeed)^16)); //getting windchill + } + return choice; + return temperature; + return windchill; + return windspeed; +} +void printdata(float (temperature), float (windchill), int (windspeed), int (choice)) +{ + if (choice == 1) + { + cout << "You chose to input your temperature in Celsius. The program has convertered the temp into Fahrenheit and the temperature is "<