Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Scanning user input text

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Thanked 0 Times in 0 Posts

    Default Scanning user input text

    Hello! Ive been trying to get user input as a text and then outputting one of 2 answers depending on the input.
    Ive also posted this on stackoverflow.com under the same title, since it may have few answers.

    import java.util.*;
    public class kt_3_1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String t;
        System.out.println("Enter the time of year");
        t = scanner.nextLine();
        if ( t.equals("summer") ) {
            System.out.printf("%n%s", t);
        }   else {

    This program compiles but always returns "FUUUUUUUu", even if Id typed "summer". What am i doing wrong?
    Last edited by ma5sacre; January 18th, 2014 at 05:41 AM. Reason: fixed a variable.

  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Thanked 329 Times in 305 Posts

    Default Re: Scanning user input text

    Thanks for mentioning your cross post, but if you provide the link to your stackoverflow question, that would be nice.

    Where does the variable vaheaeg come from?

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Thanked 0 Times in 0 Posts

    Default Re: Scanning user input text

    Sorry, had to change the code so you guys could understand and I forgot that one. fixing it now.

    --- Update ---

    The problem is now solved.
    java - Scanning user input text - Stack Overflow

Similar Threads

  1. User Input help
    By dx2731 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 13th, 2013, 12:46 AM
  2. User Input help
    By lanmonster in forum What's Wrong With My Code?
    Replies: 20
    Last Post: January 20th, 2013, 10:44 AM
  3. Take user input
    By frabbi.cse in forum Java Theory & Questions
    Replies: 1
    Last Post: July 22nd, 2012, 12:48 PM
  4. User Input with a Do Loop
    By RadiantChaos in forum Loops & Control Statements
    Replies: 4
    Last Post: March 13th, 2012, 07:14 PM
  5. Allow user input to edit text file??
    By dannyyy in forum Java Theory & Questions
    Replies: 2
    Last Post: April 6th, 2011, 06:53 AM

Tags for this Thread