public class homework8_2
public static void main(String [] args)
{
Scanner keyboard = new Scanner(System.in);
int selections = 0;
DecimalFormat formatter = new DecimalFormat("#0.0000");
do
{
showMenu();
selections = keyboard.nextInt();
System.out.println("please input the amount of meters");
double meters = keyboard.nextDouble();
if (selections == 1)
{
double kilometers;
kilometers = showKilometers(meters);
System.out.println("Kilometers = " + kilometers);
}
else if (selections == 2)
{
double inches = 0;
inches = showInches(meters);
System.out.println("inches = " + inches);
}
else if (selections == 3)
{
double feet = 0;
feet = showFeet(meters);
System.out.println("Feets = " + feet);
}
}while (selections != 4);
}
public static void showMenu()
{
System.out.println("METER CONVERSION");
System.out.println("1) Convert to kilometers");
System.out.println("2) Convert to Inches");
System.out.println("3) Convert to Feet");
System.out.println("4) Quit the program");
System.out.println("Please make the selection");
}
public static double showKilomters(double meters)
{
double kilometers = meters* 0.001;
}
public static double showInches(double meters)
{
double inches= meters * 39.37;
}
public static void showFeet(double meters)
{
double feet= meters * 3.2;
}
}
jason.angeles.75
0
Newbie Poster
Recommended Answers
Jump to PostThe first one is simply a misspelling in the definition of the
showKilometers()
method.The second is that you declared
showFeet()
ad typevoid
, when it should in fact return adouble
.On a related not, you need to have the actual
return
statements in …
All 6 Replies
jason.angeles.75
0
Newbie Poster
cool_zephyr
7
Junior Poster in Training
stultuske
commented:
yes ... a method with return type void should return a double ..... did you read your textbook? do you know what void means?
-3
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
jason.angeles.75
0
Newbie Poster
jason.angeles.75
0
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.