Convering Miles to kilometer

Page 1 of 1

6 Replies - 1780 Views - Last Post: 19 January 2013 - 09:37 PM Rate Topic: -----

#1 flynhy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-February 11

Convering Miles to kilometer

Posted 28 February 2011 - 01:52 PM

Hi guys. I have to convert mile s to kilometrs and creating two classes and then put them into a table. I found few solutions but i don`t think they`re going to work for me.
There is what i have done so far and what i have to do.
Done so far:
public static void main(Sting args[]){
		double miles
			miles = scan.netDouble();
			Scanner scan = new Scanner(System.in);
			System.out.println("Enter number of miles: ");
			float km = miles * 1.609f;
			System.out.println(miles = "miles is " + km + "kimometers.");
	}
And then what i have to do:

Write a header file that contains the following two methods:
/* convert from miles to kilometres */
Public static double mileToKilometer(double mile)

/* convert from kilometres to mile */
Public static double kilmeterToMile(double kilometre)
The formula for the conversion is:
Mile = 1.609 * kilometre
Implement the header file and write a test program that invokes these methods display the following tables:

Miles KiloMeters KiloMeters Miles
1.0 0.6215 20.0 32.180
2.0 1.2430 25.0 40.225
.....
10.0 6.2150 65.0 104.58

Analysis:
Describe the problem including input and output in your own words.

Design:
Describe the major steps for solving the problem


Please HELP

This post has been edited by japanir: 28 February 2011 - 03:18 PM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Convering Miles to kilometer

#2 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: Convering Miles to kilometer

Posted 28 February 2011 - 03:30 PM

implement the code for converting miles to kms and kms to miles into the appropriate methods.
you have been given the prototypes, so just fill the body according the formulas you haave.
then, in the main method of the class, just call the methods instaed of using the code yourself.
Also, you have compile errors in the main methods.
first declare a Scanner and then use it.
at the end of a statement use ";", like:
double miles;

Was This Post Helpful? 0
  • +
  • -

#3 flynhy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-February 11

Re: Convering Miles to kilometer

Posted 01 March 2011 - 09:22 AM

View Postjapanir, on 28 February 2011 - 03:30 PM, said:

implement the code for converting miles to kms and kms to miles into the appropriate methods.
you have been given the prototypes, so just fill the body according the formulas you haave.
then, in the main method of the class, just call the methods instaed of using the code yourself.
Also, you have compile errors in the main methods.
first declare a Scanner and then use it.
at the end of a statement use ";", like:
double miles;


Thanks Japanir,
I`ll se what i`ll do and post again.
Was This Post Helpful? 0
  • +
  • -

#4 flynhy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-February 11

Re: Convering Miles to kilometer

Posted 07 March 2011 - 01:19 PM

I`m strugaling...
Can you give me a bit more hints Japanir?
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Convering Miles to kilometer

Posted 07 March 2011 - 07:56 PM

You should create your Scanner object before using it

miles = scan.netDouble();
Scanner scan = new Scanner(System.in);
Was This Post Helpful? 0
  • +
  • -

#6 kestrel  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 5
  • Joined: 19-January 13

Re: Convering Miles to kilometer

Posted 19 January 2013 - 09:35 PM

http://www.youtube.c...h?v=O5WMCrmI6qk
:D
You can thank me later
Was This Post Helpful? -2
  • +
  • -

#7 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10185
  • View blog
  • Posts: 37,603
  • Joined: 27-December 08

Re: Convering Miles to kilometer

Posted 19 January 2013 - 09:37 PM

Please avoid pointless necroposting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1