Help with Dice Program Please

Help with this Dice Program please

Page 1 of 1

1 Replies - 1249 Views - Last Post: 16 November 2009 - 01:01 PM Rate Topic: -----

#1 bedrockhorror  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 56
  • Joined: 22-October 09

Help with Dice Program Please

Post icon  Posted 16 November 2009 - 12:50 PM

Hey guys I keep getting this error about cannot find symbol. Please help me with it because I can't find out where it's coming from. I believe it's asking me to input the scanner class which I done did, but it still want's to pop up this error.

[chriswday@cs chapter06]$ javac DiceDriver.java
DiceDriver.java:38: cannot find symbol
symbol : variable Input
location: class DiceDriver
choice = Input.readChar();
^
./Dice.java:33: cannot find symbol
symbol : variable keyboard
location: class Dice
rolls = keyboard.nextInt();
^
./Dice.java:43: cannot find symbol
symbol : variable Input
location: class Dice
aRolls = Input.readInt();
^
3 errors
[chriswday@cs chapter06]$

Here is the error in the driver
import java.util.*;

public class DiceDriver {

Scanner keyboard = new Scanner(System.in);
public static void main(String[] args)
{
 char choice; //user's choice of what he/shewants to do
 boolean done = false; //flag that tells whether user wants to quit

Dice DiceRoll = new Dice();
System.out.println("Welcome to my dice throwing simulation");

do
{
System.out.println("Options: (n)ew simulation, (a)dditional rolls," +
				   " (p)rint report, (q)uit");
System.out.print("Enter n, a, p, or q ==> ");
choice = Input.readChar();



Here is the error's in the class
import java.util.*;
public class Dice
{
Scanner Keyboard= new Scanner(System.in);

int aRolls;
final int numofRolls = 13;
int rolls;
int [] frequency = new int [numofRolls + 1];

//New Simulation
public void newSimulation()
{
int n = 12;

for (int i=2; i<n; i++)
{
frequency[i] = 0;
}
System.out.print("How many dice rolls would you like to simulate?");
rolls = keyboard.nextInt();
}

//Roll the dice additional times
public void additionalRolls()
{



System.out.print("How many additional dice rolls would you like to simulate?");
aRolls = Input.readInt();
rolls += aRolls;
results(aRolls);
}



Any help will be greatly appreciated
Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Help with Dice Program Please

#2 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1011
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: Help with Dice Program Please

Posted 16 November 2009 - 01:01 PM

once your Scanner's object name is keyboard
Scanner keyboard = new Scanner(System.in);



why do you refer to it as input
aRolls = Input.readInt();
choice = Input.readChar();



then you call it Keyboard with capital K
Scanner Keyboard= new Scanner(System.in);



and then refer to it as keyboard with lower k
rolls = keyboard.nextInt();



decide what name you want to give it! ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1