summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanturcas <[email protected]>2022-11-09 00:04:34 -0800
committerNathanturcas <[email protected]>2022-11-09 00:04:34 -0800
commit5ebec74c1a3f35f41458c8a3c917c771492af07d (patch)
treea55636592614e4c4c0b150ccbf3a12e815be8b8f
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-lab2-nathanturcas-5ebec74c1a3f35f41458c8a3c917c771492af07d.tar.xz
cst116-lab2-nathanturcas-5ebec74c1a3f35f41458c8a3c917c771492af07d.zip
commit 1
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp48
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj8
2 files changed, 51 insertions, 5 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index ed5f807..0831f32 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -9,8 +9,54 @@ using std::cout;
using std::cin;
using std::endl;
+int convertC_to_F(int Ctemp)
+{
+ float Ftemp;
+ Ftemp = Ctemp * 1.8 + 32;
+ return Ftemp;
+}
+
int main()
{
- cout << "Hello World!\n";
+ string temptype;
+ float Ftemp, Ctemp;
+
+ cout << "enter F for Fahrenhiet or C for Celcius: ";
+ cin >> temptype;
+ if (temptype == "C")
+ {
+ while (true)
+ {
+ // take input from the user
+ cout << "Enter a temperature in Celcius: ";
+ cin >> Ctemp;
+ if (Ctemp < -62 || Ctemp > 49.5)
+ cout << "Celcius value must be between -62 and 49.5" << endl;
+ else
+ break;
+ } //end C while
+
+ Ftemp = convertC_to_F(Ctemp);
+
+ cout << "Fahrenhiet temperature: ";
+ cout << Ftemp;
+
+ }
+ else
+ {
+ while (true)
+ {
+ // take input from the user
+ cout << "Enter a temperature in Fahrenheit: ";
+ cin >> Ftemp;
+ if (Ftemp < -81 || Ftemp > 121)
+ cout << "Fahrenheit value must be between -81 and 121" << endl;
+ else
+ break;
+ } // end F while
+ }
+
+
+
}
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj
index db2e734..d2e3ee2 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj
@@ -29,26 +29,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>