From fcbf951c2117a4f52bd626ad9b6ea22ea0b0f9bf Mon Sep 17 00:00:00 2001 From: DoolyBoi Date: Fri, 11 Nov 2022 01:26:57 -0800 Subject: fixed problem with code not working with online compiliers --- BlankConsoleLab/CST116-Lab2-Havaldar.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'BlankConsoleLab/CST116-Lab2-Havaldar.cpp') diff --git a/BlankConsoleLab/CST116-Lab2-Havaldar.cpp b/BlankConsoleLab/CST116-Lab2-Havaldar.cpp index 8b62d65..3919ba0 100644 --- a/BlankConsoleLab/CST116-Lab2-Havaldar.cpp +++ b/BlankConsoleLab/CST116-Lab2-Havaldar.cpp @@ -1,4 +1,5 @@ #include +#include using namespace std; @@ -38,7 +39,7 @@ Purpose: Ask user for the value of type between min and max */ void getUserInputs(float& value, float min, float max, string type) { - while (value <= min || value >= max) + while (value <= min - 1 || value >= max + 1) { cout << "What is the value of " << type << "?" << endl; cout << "(Enter a value between " << min << " & " << max << ")" << endl; @@ -65,18 +66,17 @@ Purpose: Ask user what degree they will enter temp in and run functions based of */ int main() { - string CorF; - float temp; - float wSpeed; - float windChill; + char CorF = '0'; + float temp = 999999; + float wSpeed = 999999; + float windChill = 0; - while (CorF != "C" && CorF != "F") + while (CorF != 'C' && CorF != 'F') { cout << "Do you want to enter in Fahrenheit (F) or Celsius (C)" << endl; cin >> CorF; } - - if (CorF == "F") + if (CorF == 'F') { getUserInputs(temp, Fm, FM, "Fahrenheit"); } -- cgit v1.2.3