Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- void CtoF() {// c to f furmula
- double input;
- cout << "Enter a number[Celsius-Fahrenheit]" << endl;
- cin >> input;
- cout << "it's " << input * 1.8 + 32 << " Fahrenheit " << endl;
- return;
- }
- void CtoK() {// c to k furmula
- double input;
- cout << "Enter a number[Celsius-Kelvin]" << endl;
- cin >> input;
- cout << "it's " << input + 273.15 << " Kelvin " << endl;
- return;
- }
- void FtoC() {//f to c furmula
- double input;
- cout << "Enter a number[Fahrenheit-Celsius]" << endl;
- cin >> input;
- cout << "it's " << input / 1.8 - 32 << " Celsius " << endl;
- }
- void FtoK() {//f to k furmula
- double input;
- cout << "Enter a number[Fahrenheit-Kelvin]" << endl;
- cin >> input;
- cout << "it's " << input / 1.8 - 32 + 273.15 << " Kelvin " << endl;
- return;
- }
- void KtoF() {// k to f furmula
- double input;
- cout << "Enter a number[Kelvin-Fahrenheit]" << endl;
- cin >> input;
- cout << "it's " << (input - 273.15) * 1.8 + 32 << " Fahrenheit " << endl;
- }
- void KtoC() {// k to c furmula
- double input;
- cout << "Enter a number[Kelvin-Celsius]" << endl;
- cin >> input;
- cout << "it's " <<273.15 - input << " Celsius " << endl;
- }
- void whatToWhat(char firstDegrees, char secondDegrees) {
- if (firstDegrees == 'C' || 'c') {// tests if the user want form c to f
- if (secondDegrees == 'F' || 'f') {
- CtoF();
- }
- }if (firstDegrees == 'C' || 'c') {// tests if the user want form c to k
- if (secondDegrees == 'K' || 'k') {
- CtoK();
- }
- }if (firstDegrees == 'F' || 'f') {// tests if the user want form f to c
- if (secondDegrees == 'C' || 'c') {
- FtoC();
- }
- }if (firstDegrees == 'F' || 'f') {// tests if the user want form f to k
- if (secondDegrees == 'K' || 'k') {
- FtoK();
- }
- }if (firstDegrees == 'K' || 'k') {// tests if the user want form k to f
- if (secondDegrees == 'F' || 'f') {
- KtoF();
- }
- }if (firstDegrees == 'K' || 'k') {// tests if the user want form k to c
- if (secondDegrees == 'C' || 'c') {
- KtoC();
- }
- }
- }
- int main() {
- char firstDegrees, secondDegrees;
- cout << "enter what you want to convert to what[C, K, F]" << endl;
- cin >> firstDegrees;
- cout << "to" << endl;
- cin >> secondDegrees;
- whatToWhat(firstDegrees, secondDegrees);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement