Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int choice = 0;
- float num1;
- float num2;
- int operation = 0;
- string more;
- string blank;
- bool mainExit = false;
- while (!mainExit)
- {
- cout << "Would you like to do a calculation or a conversion?? " << endl;
- cout << "Press '1' for a four function calculator " << endl;
- cout << "Press '2' to calculator a convertion between: " << endl;
- cout << "Celcius, Fahrenheit, and Kelvin. " << endl;
- cin >> choice;
- if (choice == 1)
- {
- cout << "--------------------" << endl;
- cout << "1. Addition" << endl;
- cout << "2. Subtraction" << endl;
- cout << "3. Power" << endl;
- cout << "4. Multiplication" << endl;
- cout << "5. Division" << endl;
- cout << "6. Exit" << endl;
- cout << "--------------------" << endl;
- cout << "Enter your choice: ";
- cin >> operation;
- cout << "Enter two numbers seperated by a 'space' ";
- cin >> num1 >> num2;
- bool exit = false;
- while (!exit)
- {
- if (operation == 1)
- {
- cout << num1 << " + " << num2 << " = " << (num1 + num2) << endl;
- exit = true;
- }
- else if (operation == 2)
- {
- cout << num1 << " - " << num2 << " = " << (num1 - num2) << endl;
- exit = true;
- }
- else if (operation == 3)
- {
- cout << num1 << "^" << num2 << " = " << pow(num1, num2) << endl;
- exit = true;
- }
- else if (operation == 4)
- {
- cout << num1 << " * " << num2 << " = " << (num1 * num2) << endl;
- exit = true;
- }
- else if (operation == 5)
- {
- cout << num1 << " / " << num2 << " = " << (num1 / num2) << endl;
- exit = true;
- }
- else if (operation == 6)
- {
- cout << "Bye!" << endl;
- exit = true;
- }
- else
- {
- cout << "You entered an invalid choice!";
- cout << "--------------------" << endl;
- cout << "1. Addition" << endl;
- cout << "2. Subtraction" << endl;
- cout << "3. Power" << endl;
- cout << "4. Multiplication" << endl;
- cout << "5. Division" << endl;
- cout << "6. Exit" << endl;
- cout << "--------------------" << endl;
- cout << "Enter your choice: ";
- cin >> operation;
- cout << "Enter two numbers seperated by a 'space' ";
- cin >> num1 >> num2;
- }
- }
- cout << "Type anything and press 'Enter' to exit" << endl;
- cin >> blank;
- mainExit = true;
- }
- if (choice == 2)
- {
- bool exit = false;
- float temp;
- float tempEnd;
- while (!exit)
- {
- cout << "1. Farenheit to Celsius" << endl;
- cout << "2. Celsius to Farenheit" << endl;
- cout << "3. Farenheit to Kelvin" << endl;
- cout << "Enter your choice: ";
- cin >> operation;
- if (operation == 1)
- {
- cout << "Enter your temperature in Farenheit" << endl;
- cin >> temp;
- tempEnd = ((temp - 32.0) * (5.0 / 9.0));
- cout << temp << "F = " << tempEnd << "C" << endl;
- exit = true;
- }
- else if (operation == 2)
- {
- cout << "Enter your temperature in Celcius" << endl;
- cin >> temp;
- tempEnd = ((temp * (9.0 / 5.0)) + 32.0);
- cout << temp << "C = " << tempEnd << "F" << endl;
- exit = true;
- }
- else if (operation == 3)
- {
- cout << "Enter your temperature in Farenheit" << endl;
- cin >> temp;
- tempEnd = ((temp + 459.67) * (5.0 / 9.0));
- cout << temp << "F = " << tempEnd << "K" << endl;
- exit = true;
- }
- else
- {
- cout << "You Entered an ivalid choice" << endl;
- }
- }
- cout << "Type anything and press 'Enter' to exit" << endl;
- cin >> blank;
- mainExit = true;
- }
- else
- {
- cout << "You Entered an ivalid choice" << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement