diff options
| author | Connor McDowell <[email protected]> | 2024-01-27 15:49:50 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-01-27 15:49:50 -0800 |
| commit | 0b53509d8aea4919804893355e2b862c922bedf5 (patch) | |
| tree | 4a96f87bb46d9b1ae139f5f7db93834c6cf3366d | |
| parent | homework two rough formatting (using code from exercise 5/6) (diff) | |
| download | homework-2-connormcdowell275-0b53509d8aea4919804893355e2b862c922bedf5.tar.xz homework-2-connormcdowell275-0b53509d8aea4919804893355e2b862c922bedf5.zip | |
couts and cins created, variables created, statements created.
| -rw-r--r-- | homework2/homework2.cpp | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/homework2/homework2.cpp b/homework2/homework2.cpp index 9c2ac9d..2df6cf0 100644 --- a/homework2/homework2.cpp +++ b/homework2/homework2.cpp @@ -3,42 +3,46 @@ // project reason: Homework 2 #include <iostream> +using std::cout; +using std::cin; +using std::endl; + + int main() { - int a = 0; - int b = 0; - float fah = 0.0; - float cel = 0.0; + char i; + std::cout << "Please enter C if you would like to change fahrenheit to celsius "; - int sum(int a, int b); - float percentage(int a, int b); - float FtoC(int fah); - float CtoF(int cel); + std::cout << "Or enter F if you would like to change celsius to fahrenheit "; - std::cout << percentage(45, 78) << std::endl; - std::cout << FtoC(120) << std::endl; - std::cout << CtoF(40) << std::endl; -} + cin >> i; -int sum(int a, int b) -{ - int sum = 0; - sum = a + b; + if ( i == 'C') + { + float fah = 0.0; - return sum; -} + std::cout << "you have selected fahrenheit to celsius, please enter a whole number below" << std::endl; -float percentage(int a, int b) -{ - float perc = 0; - perc = (static_cast<float>(a) / b) * 100; + cin >> fah; - return perc; -} + float FtoC(float fah); + } + + if ( i == 'F') + { + float cel = 0.0; + + std::cout << "you have selected celsus to fahrenheit, please enter a whole number below" << std::endl; + cin >> cel; + + float CtoF(int cel); + } + +} -float FtoC(int fah) +float FtoC(float fah) { // -32*5/9 @@ -47,7 +51,7 @@ float FtoC(int fah) return num; } -float CtoF(int cel) +float CtoF(float cel) { // 9/5+32 |