summaryrefslogtreecommitdiff
path: root/BlankConsoleLab
diff options
context:
space:
mode:
authorjacobdw22 <[email protected]>2022-11-02 01:41:24 -0700
committerjacobdw22 <[email protected]>2022-11-02 01:41:24 -0700
commit181c1e7898d0e00f753463f9ae16aea1cbc7221a (patch)
treef02d99b724974e2f6763a35187c67b6b0a05f31c /BlankConsoleLab
parentsimple changes (diff)
downloadcst116-lab2-jacobdw22-181c1e7898d0e00f753463f9ae16aea1cbc7221a.tar.xz
cst116-lab2-jacobdw22-181c1e7898d0e00f753463f9ae16aea1cbc7221a.zip
Made a Celsius to Fahrenheit converter.
Diffstat (limited to 'BlankConsoleLab')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index f3e4834..4b305ff 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -24,20 +24,30 @@ const float CMIN = -62; //Set values for minimum and maximum temperatures.
-int CtoF(int Celsius) {
- return Celsius;
+float CtoF(float Fahrenheit, float Celsius) {
+
+ Fahrenheit = (Celsius * 9.0 / 5.0) + 32.0; //Converts Celsius to Fahrenheit
+
+ return Fahrenheit; //Returns the newly defined fahrenheit to main
}
int main()
{
- int Celsius = 0;
+ float Celsius = 0.0; //Defines Celsius for the conversion function
+ float Fahrenheit = 0.0; //Defines Fahrenheit for the conversion function
+
+
+ if (Celsius <= 49.5 && Celsius >= -62) {
+ cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n";
+ cin >> Celsius; //Reads in Celsius from the user input
+ }
+ else{
+ cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n";
+ }
- cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n";
- cin >> Celsius;
- cout << CtoF(12) << endl;
+ cout << Celsius << " Degrees Celsius is approximately " << CtoF(Fahrenheit, Celsius) << " Degrees Fahrenheit\n\n";
- cout << "Hello World!\n";
}