#include <iostream.h>
#include <conio.h>

main()
{
   int spm, mph;
	double spmRemainder, minInHour = 60, secInHour = 3600;

   cout << "Please enter the speed  in miles per hour: ";
   cin >> mph;

   spm = secInHour / mph;
   spmRemainder = secInHour / mph;

   cout << "The speed of in minutes and seconds per mile is: " << spm << " minutes and " ;
   cout << spmRemainder << "seconds.";

   getch();
}

I have having trouble with this problem. Can you guys advise? I am not sure I am doing this right but this is what I have now. I searched around there was one using while loop. I am not sure if its necessary. I am using Borland btw. Thanks in advance

Recommended Answers

All 5 Replies

I have having trouble with this problem.

That happens a lot.

Can you guys advise?

Sure. Write the code correctly.

I am not sure I am doing this right but this is what I have now.

Neither do we, since we didn't write it. It looks like it's doing exactly what you told it to.

I searched around there was one using while loop.

And this is important how?

I am not sure if its necessary.

It might not be.

I am using Borland btw. Thanks in advance

Sure. Any time.

If you need more help, maybe you can tell us what the problem is so we have a clue what to look for. Only a couple of us are psychic.

commented: "Only a couple of us are psychic" - I knew you were going to say that ;) +19

I just cant get the output for seconds right

>> secInHour / mph

Its backwards. Its mph/secInHour

>> secInHour / mph

Its backwards. Its mph/secInHour

are you sure? I got like 0 mins and really small secs after Ive changed it

If you are going 60 miles/hour, what is the miles/minute? What is the miles/second?

Can you answer these without a program? Just pen and paper?

If so, post the answers. If not, look up the equations and figure it out. This is the first step to programming the solution.

And what is spm? Seconds/minute? Seconds/mile? And when I said "tell us what the problem is" I meant start from teh top. What are you trying to do, what values did you expect, and what did you get. Details.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.