Results 1 to 3 of 3
  1. #1
    edwed18 is offline Member
    Join Date
    Nov 2012
    Rep Power

    Default Help with Scanner

    I am trying to simulate a game of Rock-Scissors-Paper but I get one error from the java compilator. It complains about

    player=input.nextlnt(); but I fail to see what I do wrong. Here is the code for the program:

    Java Code:
    import java.util.*;
    public class RockScissorsPaper
    	public static void main(String[]args)
    	Scanner input = new Scanner(;
    	final int ROCK=0, SCISSORS=1, PAPER=2;
    	int player,computer;//human vs computer
    System.out.print("Rock:0; Scissors:1; Paper:2 --Choose:");
    computer=(int)(3*Math.random()) ; //a random number 0,1,2
    System.out.println("The computer chooses"+computer);
    if(player==computer)//both choose the same value
    	System.out.print("It´s a tie");
    	  System.out.println("Player:rock\nComputer:scissors\nPlayer wins");
    	else		//computer chooses paper
    	System.out.println("Player:rock\nComputer: paper\nComputer wins.");
    else		//player chooses scissors or paper
    		System.out.println("Player: scissors\nComputer: rock\nComputer wins.");
    else		//Computer chooses paper
    	System.out.println("Player:scissors\nComputer:paper\nPlayer wins.");
    else		//player chooses paper
    System.out.println("Player:paper\nComputer:rock\nPlayer wins.");
    else		//Computer chooses scissors
    	System.out.println("Player:paper\nComputer: scissors\nComputer wins.");

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Help with Scanner

    What is the full error message?
    That will explain what the problem is.

    You need to sort out your indenting, as that code is hard to follow.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    edwed18 is offline Member
    Join Date
    Nov 2012
    Rep Power

    Default Re: Help with Scanner

    Problem solved. The error was that I didn´t use a capital I but l instead in "player=input.nextlnt();". Thanks Tolls.

Similar Threads

  1. Scanner help
    By onions in forum New To Java
    Replies: 1
    Last Post: 04-15-2012, 02:16 PM
  2. Using scanner for CSV
    By getName() in forum Advanced Java
    Replies: 7
    Last Post: 06-20-2010, 04:33 PM
  3. Help With Scanner
    By jtmoney0511 in forum New To Java
    Replies: 10
    Last Post: 10-12-2009, 11:24 PM
  4. Need help with scanner.
    By mainy in forum New To Java
    Replies: 3
    Last Post: 07-28-2009, 02:11 PM
  5. need help with scanner
    By whiterex in forum New To Java
    Replies: 1
    Last Post: 04-22-2008, 01:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts