473,372 Members | 892 Online

# how do you convert mph to miles per second

I DON'T GET THIS
project:

Many treadmills output the speed in miles per hour. However, most runners think of their pace in minutes and seconds per mile. Write a program that inputs a decimal value for miles per hour and converts the value to minutes and seconds per mile.

Sample input, output:

For input 5.5 mph, the output should be 10 minutes and 55 seconds per mile.

For input 4 mph, the output should be 15 minutes and 0 seconds per mile.

For input 3.1mph, the output should be 19 minutes and 21 seconds per mile.

Prompt the user for his or her name and use the name to personalize the output
Nov 26 '07 #1
9 12171
sicarie
4,677 Expert Mod 4TB
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.

Then when you are ready post a new question in this thread.
Nov 26 '07 #2
weaknessforcats
9,208 Expert Mod 8TB

I can provide help only with specific problems. This one looks like oyu hare having trouble converting from miles per hour to 1 mile per ???.

Can you do this on paper?

If so, write a samll C/C++ program that does that calculation.

Then, if you are still stuck, re-post and we'll go from there.
Nov 26 '07 #3
sorry >___<;;

this is the code so far...but now, i have a problem. how would you use both minutes and seconds instead of being the seconds being a decimal?

Expand|Select|Wrap|Line Numbers
1. import java.util.Scanner;
2. public class treadmills
3. { public static void main(String[] args) {
4.
5.
6.         double x;
7.         double y;
8.         String z;
9.
10.         Scanner iScanner = new Scanner (System.in);
11.
12.         System.out.println("your name?");
13.         z = iScanner.next();
14.
15.
16.
17.
18.         System.out.println("mph?");
19.         x = iScanner.nextDouble();
20.
21.
22.         System.out.println(z+ " you are running "+(3600/x)/60+" minutes per mile");
23.
24.
25.
26.
27. }
28. }
Nov 28 '07 #4
sicarie
4,677 Expert Mod 4TB
Seeing as how this is Java code, I'm going to move it from the C/C++ Forum and over into the Java Forum.
Nov 28 '07 #5
i understand that you have to do % for division w/ remainder but i still cant get it to work
Nov 28 '07 #6
JosAH
11,448 Expert 8TB
i understand that you have to do % for division w/ remainder but i still cant get it to work
Please calm down for a minute == 60 seconds == 1/60 of an hour. You're dealing
with 'unit conversion'. Isn't that just calculus 101? there are 3600 seconds in an
hour and there are 60 minutes in an hour and there are 60 seconds in a minute.
What more do you need? A few simple methods can do the job where you
yourself have to keep track of the units:

Expand|Select|Wrap|Line Numbers
1. double convertMpHtoMpS(double mph) { return mph/3600.0; }
2. double convertMpHtoMpM(double mph) { return mph/60.0; }
3. double convertMpStoMpH(double mps) { return mps*3600.0; }
4. double convertMpMtoMpH(double mpm) { return mpm*60; }
5. // etc. etc.
6.
kind regards,

Jos
Nov 28 '07 #7
Ganon11
3,652 Expert 2GB
...Isn't that just calculus 101?...
I should hope not - I was doing unit conversion in basic science classes. But maybe that's because I'm is the US, using the silly non-SI units (inches? I'll take cm, thanks), and had to convert US units to metric units for science, and back. Then again, this doesn't even involve conversion between systems, but conversions within a system, which involved just basic knowledge of what an hour is (60 minutes) and what a minute is (60 seconds) - none of which are calculus topics.
Nov 28 '07 #8
pbmods
5,821 Expert 4TB
Heya, bakxchaixDD.

Look at it this way:

60/1 Miles/Hour = 1/60 Hours/Mile

3 Miles per hour = 1/3 Hour per Mile
12.5 Miles per hour = 1/12.5 Hours per Mile
and so on.

So to get the number of hours per mile, get the int value of the inverse (1/x) of the number of miles per hour.

3 Miles per hour = 1/3 -> 0 Hours per mile (0.3333...).

To find the number of minutes, take the decimal part and multiply by 60.

0.3333... * 60 = 20 minutes.

3 Miles per hour => 0 Hours, 20 Minutes per mile.
Nov 28 '07 #9
JosAH
11,448 Expert 8TB
I should hope not - I was doing unit conversion in basic science classes. But maybe that's because I'm is the US, using the silly non-SI units (inches? I'll take cm, thanks), and had to convert US units to metric units for science, and back. Then again, this doesn't even involve conversion between systems, but conversions within a system, which involved just basic knowledge of what an hour is (60 minutes) and what a minute is (60 seconds) - none of which are calculus topics.
I suspect it's my bad: at least the Dutch schools consider everything that has to
do with calculating stuff, calculus. Algebra comes in when you actually have to
prove that, say, a+b+c == b+a+c for a commutative operator +.

There's definitely a definition shift between Russian, Western Europe and USA
comprehension of what calculus and algebra is supposed to be.

btw, full support of abstract unit support is not trivial, e.g. if fnort == 4*fnork^2,
what is fronobulax^2/fnort? If that's solved only then you can bring in the conversion
numbers.

kind regards,

Jos ;-)
Nov 28 '07 #10