time delay to the moon
in my tutorial was a program to calculate the time delay to the mars.
the output is:
Time delay when talking to Mars: 182.796 seconds. This is 3.04659 minutes.
now i wanted to make to look like this:
Time delay when talking to Mars is 3 minutes and ?? seconds.
this is what i did:
but it didn't work out so how can i make it work?
edit: oops wrong title i mean mars. xD
the output is:
Time delay when talking to Mars: 182.796 seconds. This is 3.04659 minutes.
now i wanted to make to look like this:
Time delay when talking to Mars is 3 minutes and ?? seconds.
this is what i did:
but it didn't work out so how can i make it work?
#include <iostream>
using namespace std;
int main ()
{
double distance, lightspeed, delay, delay_in_min, seconds;
int delay_in_min_2;
/* i added int delay_in_min_2; to calculate the seconds left after the whole minutes (minutes-minutes rounded)*60 */
distance = 34000000.0;
lightspeed = 186000;
delay = distance/lightspeed;
cout << "Time delay when talking to mars: " << delay << " seconds." << endl;
delay_in_min= delay/60.0;
cout << "This is " << delay_in_min << " minutes." <<endl;
seconds = (delay_in_min-delay_in_min_2)*60;
// [Warning ] converting to int from double. how to do it else?
delay_in_min_2= ((distance/lightspeed)/60);
cout << "Time delay when talking to mars: " << delay_in_min_2 <<" minutes and " << seconds <<endl;
system ("pause");
return 0;
}
using namespace std;
int main ()
{
double distance, lightspeed, delay, delay_in_min, seconds;
int delay_in_min_2;
/* i added int delay_in_min_2; to calculate the seconds left after the whole minutes (minutes-minutes rounded)*60 */
distance = 34000000.0;
lightspeed = 186000;
delay = distance/lightspeed;
cout << "Time delay when talking to mars: " << delay << " seconds." << endl;
delay_in_min= delay/60.0;
cout << "This is " << delay_in_min << " minutes." <<endl;
seconds = (delay_in_min-delay_in_min_2)*60;
// [Warning ] converting to int from double. how to do it else?
delay_in_min_2= ((distance/lightspeed)/60);
cout << "Time delay when talking to mars: " << delay_in_min_2 <<" minutes and " << seconds <<endl;
system ("pause");
return 0;
}


By the way, did you get an error about your delay_in_min_2? I had to fix it because my compiler said unknown identifier.