aboutsummaryrefslogtreecommitdiff
path: root/Project/program.cpp
diff options
context:
space:
mode:
authoraustinlujan <[email protected]>2024-03-20 22:19:12 -0700
committeraustinlujan <[email protected]>2024-03-20 22:19:12 -0700
commitc54847448d2718db785782298647ad37c1a61732 (patch)
tree9f86136090fb5d9e8da76ec3ed1c117e5f6fb94c /Project/program.cpp
parentadd deadline (diff)
downloadhomework-2-austinlujan-main.tar.xz
homework-2-austinlujan-main.zip
assignment complete and testedHEADmain
Diffstat (limited to 'Project/program.cpp')
-rw-r--r--Project/program.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/Project/program.cpp b/Project/program.cpp
new file mode 100644
index 0000000..9e2cb82
--- /dev/null
+++ b/Project/program.cpp
@@ -0,0 +1,75 @@
+#include <iostream>
+
+using namespace std;
+
+#define VERBOSE
+
+void celsiusToFahrenheit(double celsius) {
+ double fahrenheit = 32 + (9.0 / 5.0 * celsius);
+ cout << "temperature in fahrenheit: " << fahrenheit << endl;
+#ifdef VERBOSE
+ cout << "F = 32 + (9/5 * " << celsius << ")" << endl;
+ cout << "F = " << fahrenheit << endl;
+#endif
+
+ if (celsius >= 100)
+ cout << "temp is: boiling temp\n";
+ else if (celsius >= 40)
+ cout << "temp is: very hot\n";
+ else if (celsius >= 20)
+ cout << "temp is: warm\n";
+ else if (celsius >= 10)
+ cout << "temp is: cold\n";
+ else if (celsius >= 0)
+ cout << "temp is: almost freezing\n";
+ else
+ cout << "temp is: freezing\n";
+}
+
+void fahrenheitToCelsius(double fahrenheit) {
+ double celsius = (fahrenheit - 32) * 5.0 / 9.0;
+ cout << "temperature in celsius: " << celsius << endl;
+#ifdef VERBOSE
+ cout << "C = (F - 32) * 5/9" << endl;
+ cout << "C = " << celsius << endl;
+#endif
+
+ if (celsius >= 100)
+ cout << "temp is: boiling temp\n";
+ else if (celsius >= 40)
+ cout << "temp is: very hot\n";
+ else if (celsius >= 20)
+ cout << "temp is: warm\n";
+ else if (celsius >= 10)
+ cout << "temp is: cold\n";
+ else if (celsius >= 0)
+ cout << "temp is: almost freezing\n";
+ else
+ cout << "temp is: freezing\n";
+}
+
+int main() {
+ char option;
+ double temperature;
+
+ cout << "select an option:\n";
+ cout << "1: celsius to fahrenheit\n";
+ cout << "2: fahrenheit to celsius\n";
+ cin >> option;
+
+ if (option == '1') {
+ cout << "enter temperature in celsius: ";
+ cin >> temperature;
+ celsiusToFahrenheit(temperature);
+ }
+ else if (option == '2') {
+ cout << "enter temperature in fahrenheit: ";
+ cin >> temperature;
+ fahrenheitToCelsius(temperature);
+ }
+ else {
+ cout << "invalid input\n";
+ }
+
+ return 0;
+} \ No newline at end of file