Beginner problems with Scanner

Question: what the problem

Repl link:

import java.util.Scanner;

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

    Scanner scan = new Scanner(; 
  String  n;
  int q;
    System.out.println("           menu");
    System.out.println("hotdog, burger, coke, icedtea,");
System.out.print("0 to exit");
System.out.print("                   1 to pay");
    do {
    System.out.println("whats your order");
     n = scan.nextLine();
     q = scan.nextInt();
 }while (q != 0);
    System.out.println("come again");

  while (q != 1);
       System.out.println("wait your order on counter");

:wave: Welcome to the community, @JohnCredo1!
Is there an error being raised?

1 Like

if you’re new to Java and programming, do ensure that you’re using a step-by-step tutorial. Sketch App is currently the only Java tutorial listed on replit

I can see that there’d be a blocking loop, but what do you expect your program to do?

If you want to print the variable n, you shouldn’t be putting " around it.
And to print a variable within a string, use out.printf:

System.out.printf("your order is %s", n);

Looks like you’ve since changed the code you’re using and then stopped in the middle? resturant

1 Like

after int read also end of line (CR)

      n = scan.nextLine();
      q = scan.nextInt();
      scan.nextLine(); //CR
1 Like