how do you convert mph to miles per second

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bakxchaixDD
    New Member
    • Nov 2007
    • 4

    #1

    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
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    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.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Please read the posting guidelines.

      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.

      Comment

      • bakxchaixDD
        New Member
        • Nov 2007
        • 4

        #4
        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?

        [code=java]
        import java.util.Scann er;
        public class treadmills
        { public static void main(String[] args) {


        double x;
        double y;
        String z;

        Scanner iScanner = new Scanner (System.in);

        System.out.prin tln("your name?");
        z = iScanner.next() ;




        System.out.prin tln("mph?");
        x = iScanner.nextDo uble();


        System.out.prin tln(z+ " you are running "+(3600/x)/60+" minutes per mile");




        }
        }[/code]
        Last edited by sicarie; Nov 28 '07, 04:33 PM. Reason: Code tags

        Comment

        • sicarie
          Recognized Expert Specialist
          • Nov 2006
          • 4677

          #5
          Seeing as how this is Java code, I'm going to move it from the C/C++ Forum and over into the Java Forum.

          Comment

          • bakxchaixDD
            New Member
            • Nov 2007
            • 4

            #6
            i understand that you have to do % for division w/ remainder but i still cant get it to work

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Originally posted by bakxchaixDD
              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:

              [code=java]
              double convertMpHtoMpS (double mph) { return mph/3600.0; }
              double convertMpHtoMpM (double mph) { return mph/60.0; }
              double convertMpStoMpH (double mps) { return mps*3600.0; }
              double convertMpMtoMpH (double mpm) { return mpm*60; }
              // etc. etc.
              [/code]

              kind regards,

              Jos

              Comment

              • Ganon11
                Recognized Expert Specialist
                • Oct 2006
                • 3651

                #8
                Originally posted by JosAH
                ...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.

                Comment

                • pbmods
                  Recognized Expert Expert
                  • Apr 2007
                  • 5821

                  #9
                  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.

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by Ganon11
                    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 ;-)

                    Comment

                    Working...