473,671 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do you convert mph to miles per second

4 New Member
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 12195
sicarie
4,677 Recognized Expert Moderator Specialist
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 Recognized Expert Moderator Expert
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
bakxchaixDD
4 New Member
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 Recognized Expert Moderator Specialist
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
bakxchaixDD
4 New Member
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 Recognized Expert MVP
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 Recognized Expert Specialist
...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 Recognized Expert Expert
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 Recognized Expert MVP
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
5365
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 calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm working on it but not making much progress. Is there any free code available anywhere? I know it...
4
3621
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 of the type the object is instantiated with. In my test program I have Option<std::string> and Option<long>. Here's the code for OptionBase and Option along with a small helper function. In the code are comments describing my problem, look closely...
2
2212
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
7560
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 Device(0, DeviceType.Hardware, _form, CreateFlags.SoftwareVertexProcessing, _presParams);
3
10272
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 and there you have it. So I enquired and found the Convert class with it's promising ToInt32 method, great... but it doesn't work. The thing keeps throwing Format Exceptions all over the place. What is the "C#" way to do this??? code int wmin,...
3
2533
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 like this. With the returning query include the distance from origin. Here's my dilemma, I have the script working great in VB which provides the distance, but that is not sortable, but when I port it over to TSQL I get differing results. Here is the...
2
11996
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 convert(varchar,J1708Data.dtDateTime,120), count(convert(varchar,J1708Data.dtDateTime,120))
10
11597
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: private const double MilesPerDegLat = 69.04; private const double EarthRadiusMiles = 3963.1676; private static double PiDiv180 = Math.PI / 180; double MilesPerDegLon = MilesPerDegLat * Math.Cos(Latitude * PiDiv180)
0
8402
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8927
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8676
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6237
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.