summaryrefslogtreecommitdiff
path: root/BlankConsoleLab
diff options
context:
space:
mode:
authortafaar <[email protected]>2022-11-08 18:08:04 -0800
committertafaar <[email protected]>2022-11-08 18:08:04 -0800
commitba6e8fb8563796e303e95e559ea3fa33c2bcf8e6 (patch)
tree2a4ca9c3787e065cd7008e8052479477c208d019 /BlankConsoleLab
parentmore format editing (diff)
downloadcst116-lab2-hill-ba6e8fb8563796e303e95e559ea3fa33c2bcf8e6.tar.xz
cst116-lab2-hill-ba6e8fb8563796e303e95e559ea3fa33c2bcf8e6.zip
added comments
Diffstat (limited to 'BlankConsoleLab')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index 1620263..ed4bbe7 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -39,10 +39,12 @@ float ConvertTemperature(float temperature, char initialSystem) {
bool CheckWindSpeed(float& input) {
+ // Checks to see if the value entered is between the minimum and maximum wind speeds.
+
if (input < minW || input > maxW) {
cout << "\nInvalid wind speed. Please enter a number between 0 and 231" << endl;
- return false;
+ return false; // Returns false if the value is beyond or below the range.
}
else return true;
@@ -57,7 +59,7 @@ float GetWindChill() {
windChill = 35.74 + (0.6215 * tempFahrenheit) + (pow(windSpeed, 0.16) * ((0.4275 * tempFahrenheit) - 35.75));
- return windChill;
+ return windChill; // Returns the wind chill based on what the user entered before the function has been called. Only outputs as fahrenheit.
}
@@ -71,6 +73,9 @@ int main()
bool validEntries = false;
+ // Taking input from the user until they give a valid entry.
+ // A valid entry should be a number and the character C for celsius or F for fahrenheit.
+
do {
cin >> tempInput >> tempSystem;
@@ -113,16 +118,20 @@ int main()
cout << "\nNext, enter a wind speed between 0 and 231mph. You do not need to include a unit." << endl;
+ // validEntries is just a boolean that's getting reused.
+
validEntries = false;
do {
cin >> windSpeed;
- validEntries = CheckWindSpeed(windSpeed);
+ validEntries = CheckWindSpeed(windSpeed); // If the user's input is between the minium and maximum wind speeds, this will return true.
} while (validEntries == false);
+ // Setting the wind chill values.
+
windFahrenheit = GetWindChill();
windCelsius = ConvertTemperature(windFahrenheit, 'F');
@@ -130,6 +139,8 @@ int main()
cout << "\nConversions for " << tempInput << tempSystem << " with wind speed " << windSpeed << "MPH." << endl;
+ // Printing the table.
+
cout << setprecision(2) << fixed << left << setw(20);
cout << setw(colWidth) << "\nCelsius" << setw(colWidth) << "Fahrenheit" << setw(colWidth) << "Wind Speed" << setw(colWidth) << "Wind Chill (F)" << setw(colWidth) << "Wind Chill (C)" << endl;
cout << setw(colWidth) << tempCelsius << setw(colWidth) << tempFahrenheit << setw(colWidth) << windSpeed << setw(colWidth) << windFahrenheit << setw(colWidth) << windCelsius << endl;