# get three inputs at one time, then perform the conversions on the three inputs!

• 09-06-2012, 06:43 AM
niloufar
get three inputs at one time, then perform the conversions on the three inputs!
Anybody can tell me how I get all three inputs at one time, then perform the conversions on the three inputs , and then display the results to the user!

here is my codes:

Code:

import java.util.Scanner;

/**
* Convert temperture, distance, and weight.
*/
public class UnitConversionTool {

// Declarations
public static final double METER_PER_FEET = 0.3048; // a constant value for the decimal value used in the meters
public static final double KILOGRAM_PER_POUND = 0.4536; // a constant value for the decimal value used in the kilograms
public static int Fahrenheit, Distance, Weight; // variable values

public static void main (String[] args ) {
Scanner input = new Scanner(System.in);

System.out.println("\nAuthor:  ");
System.out.println("Project 1 – Unit Conversion Tool");

// Get User inputs
System.out.print("\nEnter a Fahrenheit temperature: ");
Fahrenheit = input.nextInt();        // Gets input from the keyboard
System.out.print("Enter a distance in feet: ");
Distance = input.nextInt();
System.out.print("Enter a weight in pounds: ");
Weight = input.nextInt();

// perform the calculations
double Celsius = FahrenheitToCelsius(Fahrenheit); // invoke FahrenheitToCelsius method
double Meters = (Distance * METER_PER_FEET );
double Kilograms = (Weight * KILOGRAM_PER_POUND);

// Display result to the user
System.out.println("\n"+Fahrenheit +" Fahrenheit is  " +Celsius + " Celsius");
System.out.println(Distance +" Distance is "+ Meters+ " Meters");
System.out.println(Weight + " Weight is "+ Kilograms+ " Kilograms");

input.close(); // Close Scanner
}

/**
* Calculates Fahrenheit To Celsius method
* @param temp the Fahrenheit tempurture
* @return the tempurture
*/
public static int FahrenheitToCelsius(int Fahrenheit){
int Celsius = (Fahrenheit - 32 )*5/9;
return Celsius;
}
}

• 09-06-2012, 09:47 AM
Tolls
Re: get three inputs at one time, then perform the conversions on the three inputs!
What does "get all three inputs at one time" mean?
• 09-06-2012, 04:48 PM
niloufar
Re: get three inputs at one time, then perform the conversions on the three inputs!
Quote:

Originally Posted by Tolls
What does "get all three inputs at one time" mean?

i don't know! this was a reply from my prof. that if i do this way is better ! what do you think? can you give me an idea ?
• 09-06-2012, 05:30 PM
Tolls
Re: get three inputs at one time, then perform the conversions on the three inputs!
I really don't understand what they're meaning either I'm afraid.
The only thing I would say about your current set up is you are taking in all three things then providing answers.
I would take in the fahrenheit value and then give the answer before asking for the distance, and so on.

Which might be what they're meaning.