-
Methods
As some of you saw my other thread creating methods. Well now I have created methods but I am having problems calling for it on the main method.
These where the instructions from my instructor on how to create the method.
Write a method called convertInchesToFeet
* one parameter: inches
* returns nothing
* the method converts the number of inches to feet and inches
* the method displays the result to the user
o For example, if the method call sends 66 as the value of inches, say "Your are 5 feet and 6 inches tall"
* notice you are outputing the information to the user from inside the method, not returning the value to main
The code is
Code:
public static void convertinchestofeet(int inches)
{
int feet = inches / 12;
int pInches = inches % 12;
System.out.println("You are" + feet +"feet and" + pInches + "inches tall.");
}// end ConvertInchesToFeet Method
Then the instructions for my main method are:
says "Let's convert inches to feet" then
* prints a blank line
* Asks the user to enter the total number of inches tall he is
* calls the convertInchesToFeet method
my code is Code:
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Let's convert inches to feet\n");
System.out.print("Enter the total number of inches tall you are:");
int height = scanner.next();
Now i have having trouble linking both methods and performing the actions my teachers asks for. Can anybody help me?
-
Umm, I'm pretty sure I already answered your question in the other thread.
Classname.convertInchesToFeet(height);
-
yeah but it aint working for me
-