473,372 Members | 892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
2
by: Galsaba | last post by:
How can I convert the following script to be used in access? <Html> <head> <title>Dealers</title> </head> <h5>List of Dealers Nearest to your Zip Code</h5><br><br> <? $errflag = false;
4
by: Daisy | last post by:
Having a weird problem... Just moving some code into new classes & methods. Originally, I created a new instance of "Game" (my form), and it created a new DX Device using: _device = new...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
3
by: David Lozzi | last post by:
Howdy, ISSUE 1: See issue 2 below. I have a distance calculator on my site which works great. However, the users need to sort by distance, which make sense. I'm not sure how to do it other than...
2
by: kirke | last post by:
Hi, I have a datetime column named dtDateTime. its format is "Oct 27 2006 12:00:00 " I want to group by only date part of it and count my code is $sql1="SELECT ...
10
by: Joseph Geretz | last post by:
I need to calculate miles per degree longitude, which obviously depends on latitude since lines of longitude converge at the poles. Via Google, I've come up with the following calculation: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.