-2

I'm doing a small project and I have everything done, just one small error. the error shows "symbol not found" and shows the red squiggly line under my scan.

package pkgif.elsestatements.java;

import java.util.Scanner;
public class IfElseStatementsJava {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner user_input = new Scanner(System.in);

        String your_name;
        System.out.print("What is your name?");
        your_name = user_input.next();

         System.out.println("Hi " + your_name);

         String user_input2;
        System.out.print(".");
        user_input2 = user_input.next();

         System.out.println("Do you like Gospel Music Paul?"); //Asks question

     String input = scan.nextLine(); //Waits for input
     if (input.equalsIgnoreCase("Yes")) { //If the input is Yes)
          System.out.println("Here are some songs; Amazing Grace, I'll Fly Away, A Little Talk With Jesus ");
     }
     else { //If the input is anything else
          System.out.println("Ok! Have a nice day!");



    }

}

this line is the one giving me trouble ---- String input = scan.nextLine(); //Waits for input

I was feeling really great about finish this with no errors beforehand, then this. Any help is appreciated.

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
Timothy
  • 3
  • 3

1 Answers1

2

According to the code above. You've defined Scanner user_input = new Scanner(System.in); i.e. user_input as the oject ref. So, changing String input = scan.nextLine(); to String input = user_input.nextLine(); should do.

Neha
  • 3,456
  • 3
  • 14
  • 26
  • This fixed my problem, Thx!!! This is my first time messing with any software like this, so forgive me if i overlook anything like this. – Timothy Jan 16 '18 at 00:55