Need help

i need to make this program be able to accept input on whether you wanna enter Fahrenheit, kelvin, or Celsius and then it will display the other options depending on what you input this is a practice i gave my self but i can't figure it out. Link to pastebin: https://pastebin.com/39pCrdi9
rickbagent wrote:
Link to pastebin: https://pastebin.com/39pCrdi9


The code the OP means at the link is below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <limits>

using namespace std;

double f;
double c;
double k;
double result;


int main()
{
    cout << "Pick a temperature unit K for Kelvin, F for Fahrenheit, C for Celsius: ";
    cin >> result;
    cout << endl;
    if(result == 'f' || result == 'F')
    {
        cout << "This program will tell you what the degrees where you live is in Kelvin and Celsius." << endl;
        cout << endl;
        cout << "What's your temperature in Fahrenheit: ";
        
        while(!(cin >> f)){        
            cin.clear();
            cin.ignore(numeric_limits<streamsize>::max(), '\n');
            cout << "Invalid temperature try again. ";
            cout << endl;
            cout << "What's your temperature in Fahrenheit: ";
    }
        cout << endl;
        
        k = c + 273.15;    
        cout << "Your degrees in Kelvin is: " << setprecision(3) << k << " Kelvin" << endl;
        cout << endl;
        
        c = (f - 32) * 5 / 9;           
        cout << "Your degrees in Celsius is: " << setprecision(2) << c << "Celsius" << endl;
        cout << endl;                       
    }
    
    if(result == 'c' || result == 'C')
    {
    cout << "This program will tell you what the degrees where you live is in Kelvin and Fahrenheit." << endl;
    cout << endl;
    cout << "What's your temperature in Celsius: ";
    
    while(!(cin >> c)){        
        cin.clear();
        cin.ignore(numeric_limits<streamsize>::max(), '\n');
        cout << "Invalid temperature try again. ";
        cout << endl;
        cout << "What's your temperature in Celsius: ";
    }
        cout << endl;
        
        k = c + 273.15;    
        cout << "Your degrees in Kelvin is: " << setprecision(3) << k << " Kelvin" << endl;
        cout << endl;
        
        (f = (c × 9/5) + 32);    
        cout << "Your degrees in Fahrenheit is: " << setprecision(2) << f << "Fahrenheit" << endl;
        cout << endl;
        
    }
    
    if(result == 'k' || result == 'K')
    {
    cout << "This program will tell you what the degrees where you live is in Fahrenheit and Celsius." << endl;
    cout << endl;
    cout << "What's your temperature in Kelvin: ";
    
    while(!(cin >> k)){        
        cin.clear();
        cin.ignore(numeric_limits<streamsize>::max(), '\n');
        cout << "Invalid temperature try again. ";
        cout << endl;
        cout << "What's your temperature in Kelvin: ";
    }
        cout << endl;
        
        f = (k − 273.15) × 9/5 + 32;
        cout << "Your degrees in Fahrenheit is: " << setprecision(2) << f << "Fahrenheit" << endl;
        cout << endl;
        
        c = (f - 32) * 5 / 9;           
        cout << "Your degrees in Celsius is: " << setprecision(2) << c << "Celsius" << endl;
        cout << endl;    
    }  

    
   
    if (f <= 65)
    {
        cout << "It must be chilling outside don't forget a coat." << endl;
    }    
    if (f >= 75)
    {        
        cout << "It's pretty warm out no need for a coat." << endl;       
    }
    if (f > 65 && f < 75)
    {
        cout << "It's a little cold but you should need a coat hopefully" << endl;
    }
    return 0;        
}
Last edited on
Topic archived. No new replies allowed.