A problem

Hi; I'm trying to make it optional whether the time is presented in minutes, but I can't do it/don't know how/don't know why what I've done is not working.
With what I've written it displays in minutes whatever is button is pressed, and not just for the y (yes).

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
#include <iostream>

using namespace std;
int main()
{
    double distance;
    double speed;
    double result;
    double RM;
    char y,n;


    distance= 34000000;
    speed= 186000;

    result=distance/speed;
    cout<< "The delay is " << result<< " seconds \n";
    if (cin>> y)
{


    RM= result/60;
    cout<< "In minutes this is "<< RM;
    }
    if (cin>>n)
    return 0;
}
You cannot write if (cin>> y) .... You need something like
1
2
3
cin>> y;
if (y == 'y') ...
else  ......
Topic archived. No new replies allowed.