Ask Experts Questions for FREE Help !
Ask
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #1

    Oct 13, 2007, 01:06 PM
    using string class
    I'm not entirely sure what I'm doing wrong but I think whatever it is, is part of my 'is' statement, I'm trying to get the program to tell if user input is valid or not.

    import java.util.*; // the package containing Scanner
    public class Name1

    {
    public static void main(String[] args)
    {

    //input

    Scanner kybd = new Scanner(System.in);

    System.out.println("Enter A Phrase");

    String phrase = kybd.nextLine();

    String name1 = "Cathy";
    String name2 = "Pete";
    String name3 = "Graham";

    if ((name1)||(name2)||(name3))

    System.out.println ("Data entered is valid");
    }
    }
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #2

    Oct 13, 2007, 01:48 PM
    Anybody?
    albear's Avatar
    albear Posts: 1,594, Reputation: 222
    Ultra Member
     
    #3

    Oct 13, 2007, 02:24 PM
    Anything at all...
    qcumber's Avatar
    qcumber Posts: 5, Reputation: 1
    New Member
     
    #4

    Nov 14, 2007, 09:29 PM
    Should be

    If( phrase.equals(name1) || phrase.equals(name2) || phrase.equals(name3) )
    {
    System.out.println ("Data entered is valid");
    }

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search


Check out some similar questions!

Wha does class e and class b mens [ 8 Answers ]

Hello I live in the state of ma. My question is what does class e means and class b for license electricians.

Weedeater string [ 1 Answers ]

Which way do you wind weedeater string? Is it always the same direction?

New string in string Trimer [ 1 Answers ]

How do I put new string in string Trimer. Bump Type kevant

String Trimmer [ 1 Answers ]

I purchased a Troy Bilt string trimmer that came with dual (fused twin .105) string cord. No one stocks dual fused cord, even the place I bought it which was Lowe's, Also very few even have .105 single cord. Where can I get some?

My string trimmer [ 1 Answers ]

How do I put new string on my trimmer


View more questions Search