aboutsummaryrefslogtreecommitdiff
path: root/homework-2/Source.cpp
diff options
context:
space:
mode:
authorraquelc <[email protected]>2024-01-29 20:07:36 -0800
committerraquelc <[email protected]>2024-01-29 20:07:36 -0800
commitd69e94483a67629a8ed2b38e31e1e96a37ebcf64 (patch)
tree8b2e274a8f828f52eb374b1e9e88dbc944e4cd61 /homework-2/Source.cpp
parentadd deadline (diff)
downloadhomework-2-raquel191-main.tar.xz
homework-2-raquel191-main.zip
complete hw2HEADmain
Diffstat (limited to 'homework-2/Source.cpp')
-rw-r--r--homework-2/Source.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/homework-2/Source.cpp b/homework-2/Source.cpp
new file mode 100644
index 0000000..5520ff5
--- /dev/null
+++ b/homework-2/Source.cpp
@@ -0,0 +1,83 @@
+// Name: Raquel Chavez
+// Date: 1/26/2024
+// Class: CST 116
+// Homework 2
+#define VERBOSE
+
+#include <iostream>
+#include "header.h"
+
+int main() {
+ int enter_num;
+ std::cout << "To change celsius to Fahrenheit enter 0 " << std::endl;
+ std::cout << "To change Fahrenheit to Celsius enter 1 " << std::endl;
+ std::cin >> enter_num;
+
+ int i;
+ std::cin >> i;
+
+
+ switch (enter_num) {
+ case 0:
+
+ std::cout << CtoF(i) << std::endl;
+ if (i < 40) {
+ std::cout << "It is cold" << std::endl;
+ }
+ else if (i > 80) {
+ std::cout << "It is hot" << std::endl;
+ }
+ break;
+ case 1:
+
+ std::cout << FtoC(i) << std::endl;
+ if (i > 15) {
+ std::cout << "It is cold" << std::endl;
+ }
+ else if (i < 15) {
+ std::cout << "it is hot" << std::endl;
+ }
+
+ break;
+
+ default:
+ std::cout << " Number invalid" << std::endl;
+ break;
+ }
+#ifdef VERBOSE
+ switch (enter_num){
+ case 1:
+ std::cout << i << "F to C " << std::endl;
+ std::cout << i << " - 32 * (5/9)" << std::endl;
+ std::cout << "C = " << FtoC(i) << std::endl;
+ break;
+ case 0:
+ std::cout << i << "C to F " << std::endl;
+ std::cout << i << " (9/5) + 32" << std::endl;
+ std::cout << "F = " << CtoF(i) << std::endl;
+ break;
+ }
+#endif;
+
+
+ return 0;
+};
+
+
+float FtoC(int fah) {
+ // -32 *5/9
+
+ float num = static_cast<float>(fah - 32) *(5.0 / 9.0);
+
+ return num;
+}
+
+
+float CtoF(int cel) {
+ // 9/5+32
+
+ float num = static_cast<float>(cel) * (9.0 / 5.0) + 32;
+
+ return num;
+}
+