Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // temp conversion
- #include <iostream>
- int convert_fahrenheit();
- int convert_celsius();
- int main()
- {
- std::cout << "Please indicate your choice of temperature scale with f for 'fahrenheit' or c for 'celsisu'." << std::endl;
- char tempscale;
- std::cin >> tempscale;
- if (tempscale == 'f')
- {
- convert_fahrenheit();
- }
- else if (tempscale == 'c')
- {
- convert_celsius();
- }
- else
- {
- std::cout << "That is not a correct input. Please rerun this program." << std::endl;
- }
- return 0;
- }
- int convert_fahrenheit()
- {
- int temperature;
- std::cout << "Please enter your temperature in degrees fahrenheit." << std::endl;
- std::cin >> temperature;
- int temprevised = temperature - 32;
- std::cout << "The temperature in degrees celsius is " << temprevised * 5/9 << std::endl;
- return 0;
- }
- int convert_celsius()
- {
- int temperature;
- std::cout << "Please enter your temperature in degrees celsius." << std::endl;
- std::cin >> temperature;
- std::cout << "The temperature in degrees fahrenheit is " << temperature * 9/5 - 32 << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement