Results 1 to 5 of 5
Thread: Mph to Kph Algorithm
- 01-21-2013, 05:40 AM #1
Member
- Join Date
- Jan 2013
- Posts
- 2
- Rep Power
- 0
Mph to Kph Algorithm
Hi, I am working on a program that converts user input from mph to kph. It is for a long term project I am working on from a textbook to teach myself java. I am using a class called convert.class to convert a string to a double. So far I have:
public class ConvertMphToKph
{
public static void main(String[] args)
{
double milesPK;
milesPK = .6214;
double kilometersPerHour, milesPerHour;
convert.toNonNegativedouble(double kilometersPerHour);
kilometersPerHour = milesPerHour / milesPK
System.out.println(args[0]);
}
}
My code doesnt work though. What am I doing wrong. Thanks.
-Julie
- 01-21-2013, 06:25 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 762
- Rep Power
- 14
Re: Mph to Kph Algorithm
Hi,
The first error is in the following line:
Java Code:convert.toNonNegativedouble(double kilometersPerHour);
Website: Learn Java by Examples
- 01-21-2013, 07:10 AM #3
Member
- Join Date
- Jan 2013
- Posts
- 2
- Rep Power
- 0
- 01-21-2013, 09:17 AM #4
Re: Mph to Kph Algorithm
If you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 01-21-2013, 09:26 AM #5
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 762
- Rep Power
- 14
Re: Mph to Kph Algorithm
When you call a method you only pass the argument such as:
Java Code:Convert.toNonNegativedouble(kilometersPerHour);
Java Code:public double toNonNegativedouble(double kilometersPerHour) { ... }
Website: Learn Java by Examples
Similar Threads
-
all i need is algorithm
By naved in forum New To JavaReplies: 4Last Post: 04-06-2011, 03:34 PM -
Algorithm help? :)
By Mirix in forum New To JavaReplies: 6Last Post: 05-24-2010, 03:08 AM -
Need some help in an algorithm
By ea09530 in forum New To JavaReplies: 3Last Post: 04-04-2010, 02:13 PM -
Help with an Algorithm
By Manfizy in forum New To JavaReplies: 22Last Post: 07-03-2009, 08:16 AM -
O(log n) algorithm help !!!!!!
By itseeker87 in forum New To JavaReplies: 8Last Post: 09-09-2008, 06:12 PM
Bookmarks