The Artima Developer Community
Sponsored Link

Java Answers Forum
HELP!!! input = keyboard.nextLine();

4 replies on 1 page. Most recent reply: Oct 15, 2009 6:15 AM by George B

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Nay B

Posts: 9
Nickname: blackrose
Registered: Oct, 2009

HELP!!! input = keyboard.nextLine(); Posted: Oct 13, 2009 5:00 PM
Reply to this message Reply
Advertisement
I cannot figure out how to fix this error message - can anyone please help!!

K:\Homework\Java\StateA.java:13: cannot find symbol
symbol : variable keyboard
location: class StateA
input = keyboard.nextLine();
^
1 error

Tool completed with exit code 1


--------------------------------------------------------
Here's my code:
***************

import java.util.Scanner;

public class StateA
{
public static void main (String[]args)
{
String input;

Scanner kayboard = new Scanner(System.in);

System.out.println("Please enter one of the following state abbreviations: ");
System.out.println("NC, SC, GA, FL, or AL");
input = keyboard.nextLine();

if (input.equalsIgnoreCase("NC"))
{
System.out.println("You've entered the abbreviation for North Carolina");
}
else if (input.equalsIgnoreCase("SC"))
{
System.out.println("You've entered the abbreviation for North Carolina");
}
else if (input.equalsIgnoreCase("GA"))
{
System.out.println("You've entered the abbreviation for North Carolina");
}
else if (input.equalsIgnoreCase("FL"))
{
System.out.println("You've entered the abbreviation for North Carolina");
}
else if (input.equalsIgnoreCase("AL"))
{
System.out.println("You've entered the abbreviation for North Carolina");
}
else
{
System.out.println("You've entered an incorrect abbreviation");
}
}
}


Nay B

Posts: 9
Nickname: blackrose
Registered: Oct, 2009

Re: HELP!!! input = keyboard.nextLine(); Posted: Oct 13, 2009 5:03 PM
Reply to this message Reply
ignore the fact that every System.out.println has "...NORTH CAROLINA"

I just need help with the error, i really dont see what's wrong..

thanks for all your help.. much appreciated, you have no idea lol.

George B

Posts: 24
Nickname: hmgeorge
Registered: Feb, 2008

Re: HELP!!! input = keyboard.nextLine(); Posted: Oct 14, 2009 5:51 AM
Reply to this message Reply
You misspelled keyboard as "kayboard" on the line where it was declared:

Scanner kayboard = new Scanner(System.in);

xinzhi zhang

Posts: 2
Nickname: zhangxzhi
Registered: Sep, 2009

Re: HELP!!! input = keyboard.nextLine(); Posted: Oct 15, 2009 2:00 AM
Reply to this message Reply
Can you pass the compilation.

George B

Posts: 24
Nickname: hmgeorge
Registered: Feb, 2008

Re: HELP!!! input = keyboard.nextLine(); Posted: Oct 15, 2009 6:15 AM
Reply to this message Reply
> Can you pass the compilation.

If I change kayboard to keyboard it compiles fine.

Flat View: This topic has 4 replies on 1 page
Topic: Help needed turning this program into 2-class and demo.. plz help Previous Topic   Next Topic Topic: Pass the array please..

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use