aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevidavis04 <[email protected]>2022-10-12 15:28:05 -0700
committerGitHub <[email protected]>2022-10-12 15:28:05 -0700
commitfcf8a4c81a101f971b420e0d3a1daf0ab6b20869 (patch)
tree75538bdefc77ca8f0afc03f0830bdfb831b8b23f
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-ch6-debugging-levidavis04-fcf8a4c81a101f971b420e0d3a1daf0ab6b20869.tar.xz
cst116-ch6-debugging-levidavis04-fcf8a4c81a101f971b420e0d3a1daf0ab6b20869.zip
Add files via upload
-rw-r--r--CST116-Ch6.Debugging-PseudoCode-Davis.rtf18
-rw-r--r--CST116-ch6DebuggingOutput-Davis.rtf17
-rw-r--r--main.cpp62
3 files changed, 97 insertions, 0 deletions
diff --git a/CST116-Ch6.Debugging-PseudoCode-Davis.rtf b/CST116-Ch6.Debugging-PseudoCode-Davis.rtf
new file mode 100644
index 0000000..6b3c4a8
--- /dev/null
+++ b/CST116-Ch6.Debugging-PseudoCode-Davis.rtf
@@ -0,0 +1,18 @@
+{\rtf1\ansi\ansicpg1252\cocoartf2639
+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+{\*\expandedcolortbl;;}
+\margl1440\margr1440\vieww11520\viewh8400\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
+
+\f0\fs24 \cf0 PseudoCode\
+\
+Set Fahrenheit to 0\
+Set Celcius to 0\
+\
+Print \'93Enter temperature in Fahrenheit: \'93\
+User entry = Fahrenheit\
+\
+Celsius = 5.0 / 9.0 * (Fahrenheit - 32)\
+\
+Print \'93(user entry) degrees F = (Celsius) degrees C\'94} \ No newline at end of file
diff --git a/CST116-ch6DebuggingOutput-Davis.rtf b/CST116-ch6DebuggingOutput-Davis.rtf
new file mode 100644
index 0000000..1b03044
--- /dev/null
+++ b/CST116-ch6DebuggingOutput-Davis.rtf
@@ -0,0 +1,17 @@
+{\rtf1\ansi\ansicpg1252\cocoartf2639
+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Menlo-Bold;\f2\fnil\fcharset0 Menlo-Regular;
+}
+{\colortbl;\red255\green255\blue255;\red255\green255\blue255;\red0\green0\blue0;}
+{\*\expandedcolortbl;;\cssrgb\c100000\c100000\c100000;\cssrgb\c0\c0\c0;}
+\margl1440\margr1440\vieww12140\viewh8400\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
+
+\f0\fs24 \cf0 Output: \
+\
+\pard\tx593\pardeftab593\pardirnatural\partightenfactor0
+
+\f1\b \cf2 \cb3 Enter temperature in Fahrenheit:
+\f2\b0 212
+\f1\b \
+212 degrees F = 100 degrees C\
+Program ended with exit code: 0} \ No newline at end of file
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..0cb81f0
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,62 @@
+//
+// main.cpp
+// CST116-ch6 debugging-Davis
+//
+// Created by Levi on 10/10/22.
+//
+/********************************************************************
+* Debugging Exercise 1
+*
+* 1) On the lines indicated in the code below, insert a breakpoint.
+* 2) Run to the breakpoint.
+* 3) Put watches on both Fahrenheit and Celsius.
+* 4) When asked for a temperature, enter 212.
+* 5) Verify that the value you entered is stored correctly.
+* 6) Step over the conversion calculation. What is the value
+* in Celsius? Is that the correct value? No.
+* 7) Remember your order of precedence. Put parentheses around
+* Fahrenheit - 32. This needs to be done before the multiplication.
+* 8) Stop debugging and recompile.
+*
+* Debugging Exercise 2
+*
+* 1) Run to Breakpoint 1.
+* 2) When asked for a temperature, enter 212.
+* 3) Verify that the value you entered is stored correctly.
+* 4) Step over the conversion calculation. What is the value
+* in Celsius? Is that the correct value? No.
+* 5) Look at the division. This is integer division. Therefore,
+* 5 / 9 = 0. This is not the result we are looking for.
+* 6) Modify the calculation so that it does floating point division.
+* There are three different ways we have discussed:
+* a) use the F suffix on the literals
+* b) type cast the literals
+* c) replace the 5 with 5.0 and the 9 with 9.0
+* 7) Stop debugging, recompile and run to verify that it now works
+* correctly.
+********************************************************************/
+#include <iostream>
+#include <iomanip>
+using std::cout;
+using std::cin;
+using std::endl;
+
+
+
+int main()
+{
+ float fahrenheit;
+ float celcius = 0;
+
+ cout << "Enter temperature in Fahrenheit: ";
+ cin >> fahrenheit;
+
+
+
+ celcius = 5.0 / 9.0 * (fahrenheit - 32);
+
+ cout << fahrenheit << " degrees F = "
+ << celcius << " degrees C" << endl;
+
+ return 0;
+}