0
public static void battle() {
    Scanner b = new Scanner(System.in); //collect data
    System.out.println("What is your Attack? ");
    int attack = b.next();
    System.out.println("What is your Defence? ");
    int defence = b.next();
    System.out.println("What is your Base? ");
    int base = b.next();
    System.out.println("What is your STAB? ");
    int stab = b.next();
    System.out.println("What is your HP? ");
    int hp = b.next();
    System.out.println("What is your Level?");
        int level = b.next();
        //print data colected   
        System.out.println("=============================================================");
            System.out.println("You are fighting mew!\n Your stats:");
            System.out.println("\nLevel: " + level + "\nAttack: " + attack + "\nDefence: " + defence + "\nBase: " + base + "\nStab:" + stab + "\nHP: " + hp);
        System.out.println("=============================================================");
}

I've been learning java solo for about 2 weeks. I'm trying to do this one programming worksheet where the computer asks the user for Pokemon stats input, then prints the stat list back to them. I'm making some stupid syntax error and it should be obvious but I'm spacing on it.

Mark Rotteveel
  • 82,132
  • 136
  • 114
  • 158
  • Does this answer your question? [How can I read input from the console using the Scanner class in Java?](https://stackoverflow.com/questions/11871520/how-can-i-read-input-from-the-console-using-the-scanner-class-in-java) – pppery Oct 23 '20 at 20:57

1 Answers1

1

Use nextInt If you check the javadocs https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#next() you will seee next returns an String

    Scanner b = new Scanner(System.in); //collect data
    System.out.println("What is your Attack? ");
    int attack = b.nextInt();
    System.out.println("What is your Defence? ");
    int defence = b.nextInt();
    System.out.println("What is your Base? ");
    int base = b.nextInt();
    System.out.println("What is your STAB? ");
    int stab = b.nextInt();
    System.out.println("What is your HP? ");
    int hp = b.nextInt();
    System.out.println("What is your Level?");
    int level = b.nextInt();
    //print data colected   
    System.out.println("=============================================================");
    System.out.println("You are fighting mew!\n Your stats:");
    System.out.println("\nLevel: " + level + "\nAttack: " + attack + "\nDefence: " + defence + "\nBase: " + base + "\nStab:" + stab + "\nHP: " + hp);
    System.out.println("=============================================================");
Scary Wombat
  • 41,782
  • 5
  • 32
  • 62