So I'm supposed to create a pretty simple program that asks the user for their name. The user will then enter their name and if it is less than 9 letters long, it will display the name. Otherwise the program will say that the name is too long.
This is what I have so far:
I don't understand how to use the showLength method and have the program count the characters in the name. We're supposed to use displayName as well. I know I'm supposed to use a condition if-statement to either display the name or tell if it is too long but don't know how to go about it. Any tips?
This is what I have so far:
import java.util.*;
public class Methods
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter name: ");
String name=input.nextLine();
System.out.println("Your name is "+ name);
}
}
I don't understand how to use the showLength method and have the program count the characters in the name. We're supposed to use displayName as well. I know I'm supposed to use a condition if-statement to either display the name or tell if it is too long but don't know how to go about it. Any tips?