Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

The displayName() method

$
0
0
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:
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?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>