summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrenton Stark <[email protected]>2022-11-05 12:02:43 -0700
committerTrenton Stark <[email protected]>2022-11-05 12:02:43 -0700
commit3a1d2566d92e312997509d46bbb00e64c19f1c85 (patch)
treebc085936586e51a62f5394f21bcfc7dfec081b92
parentMove temperature input to a function. (diff)
downloadcst116-lab2-stark-3a1d2566d92e312997509d46bbb00e64c19f1c85.tar.xz
cst116-lab2-stark-3a1d2566d92e312997509d46bbb00e64c19f1c85.zip
Fixed integer division.
-rw-r--r--BlankConsoleLab/cst116-lab2-stark.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/BlankConsoleLab/cst116-lab2-stark.cpp b/BlankConsoleLab/cst116-lab2-stark.cpp
index 327cb11..b20630d 100644
--- a/BlankConsoleLab/cst116-lab2-stark.cpp
+++ b/BlankConsoleLab/cst116-lab2-stark.cpp
@@ -19,6 +19,8 @@ int main() {
cout << "Welcome to Cold Calculator v0.2" << endl;
inputTemp(cTemp, fTemp);
+ cout << cTemp << endl;
+ cout << fTemp << endl;
}
void inputTemp(float& cTemp, float& fTemp) {
@@ -63,10 +65,10 @@ float tempConverter(float temp, bool dirc) {
float cTemp;
if (dirc == 0) {
- cTemp = (temp * (9 / 5)) + 32;
+ cTemp = (temp * (9.0 / 5.0)) + 32;
}
else {
- cTemp = (temp - 32) * (5/9);
+ cTemp = (temp - 32) * (5.0 / 9.0);
}
return cTemp;