diff options
| author | alexandra-apetroaei <andra@MSI> | 2022-10-29 10:12:53 -0800 |
|---|---|---|
| committer | alexandra-apetroaei <andra@MSI> | 2022-10-29 10:12:53 -0800 |
| commit | f82c65b56436816eedbb10048fba141061e8cd8f (patch) | |
| tree | fe7c454b1040e1dd90db3df6a4ce3a033aa5286f | |
| parent | first step (diff) | |
| download | cst116-lab2-alexandra-apetroaei-f82c65b56436816eedbb10048fba141061e8cd8f.tar.xz cst116-lab2-alexandra-apetroaei-f82c65b56436816eedbb10048fba141061e8cd8f.zip | |
| -rw-r--r-- | BlankConsoleLab.sln | 4 | ||||
| -rw-r--r-- | BlankConsoleLab/Project2-Apetroaei.cpp | 39 |
2 files changed, 25 insertions, 18 deletions
diff --git a/BlankConsoleLab.sln b/BlankConsoleLab.sln index 8e981c8..71b5dea 100644 --- a/BlankConsoleLab.sln +++ b/BlankConsoleLab.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31911.196 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32922.545 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlankConsoleLab", "BlankConsoleLab\BlankConsoleLab.vcxproj", "{3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}" EndProject diff --git a/BlankConsoleLab/Project2-Apetroaei.cpp b/BlankConsoleLab/Project2-Apetroaei.cpp index ef526e3..a874a61 100644 --- a/BlankConsoleLab/Project2-Apetroaei.cpp +++ b/BlankConsoleLab/Project2-Apetroaei.cpp @@ -10,40 +10,47 @@ using std::cin; using std::string; using std::endl; -int float fahr; -int float cel; -int float mph; - -char input; -char menu; int main() { + + float fahr; + float cel; + float mph; + + char menu_choice; + //ask user to choose temperature calculations - cout << "Do you want to enter temperature in Farenheit? or Celcius?" << endl; + cout << "Do you want to enter temperature in no? or Celcius?" << endl; cout << "Options: Farenheit (f) Celcius (c)." << endl; - //converter to use - cin >> input; + cin >> menu_choice; //if user types f, using farenheit - if (input == 'f') + if (menu_choice == 'f') { // ask user to input temperature cout << "Please enter temperature in Farenheit:" << endl; cin >> fahr; - //Display result of calculation + //Display result of calculation: + cout << "Here is the temperature in Farenheit:" << endl; + cout << fahr << endl; } + //if user types c, using celcius - else if (input == 'c') + else (menu_choice == 'c') { - cout << "Please enter temperature in Celcius:" << endl; + cout << "Please enter temperature in my:" << endl; cin >> cel; - fahr = ((cel * 9.0 / 5.0) + 32.0); + //formula to convert celcius to farenheit + fahr = (1.8 * cel) + 32; - } + //display results of claculation + cout << "Here is the temperature in Farenheit:" << fahr << endl; - return 0; + + } + return 0; }
\ No newline at end of file |