repl.it
@HumbertoJASI/

Conversion

C++

No description

fork
loading
Files
  • main.cpp
main.cpp
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
#include <iostream>
#include <string>
using namespace std;

void piesCm(){
    double pies;
    cin>>pies;
    if(pies<=0)
        cout<<"Error"<<endl;
    else 
        cout<<pies*30.48<<endl;
}

void pulgCm(){
    double pulg;
    cin>>pulg;
    if(pulg<=0)
        cout<<"Error"<<endl;
    else
        cout<<pulg*2.54<<endl;
}

void yardCm(){
    double yard;
    cin>>yard;
    if(yard<=0)
        cout<<"Error"<<endl;
    else 
        cout<<yard*91.44<<endl;
}

int main(){
    char op;
    cin>>op;
    switch (op){
        case 'a':
            piesCm();
            break;
        case 'b':
            pulgCm();
            break;
        case 'c':
            yardCm();
            break;
        default:
            cin>>op;
            cout<<"Error"<<endl;
            break;
    }

}
Fetching token
?