Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Nov 27th, 2005, 5:19 PM   #1
ps2cho
Newbie
 
Join Date: Nov 2005
Posts: 2
Rep Power: 0 ps2cho is on a distinguished road
What is wrong with this code?

[code]//***********************************************************************
// xxxxx Project 4-4 11/26/05
// Design and implement a class called PairOfDice, with two six-sided
// Die objects. Create a driver class called BoxCars with a main method
// that rolls a PairOfDice object 1000 time, counting the number of box
// cars (two sixes) that occur.
//***********************************************************************

import cs1.Keyboard;
import java.util.Random;
import java.lang.Math;

public class P4_4
{

int sides = 6;
// Creates the 2 die objects + and rolls them.
Die Dice1 = new Die(sides);
Die Dice2 = new Die(sides);
Dice1.roll();
Dice2.roll();
System.out.println("You rolled a " +die1 +die2);



// rolls the dice.
public void roll()
{
DiceRoll = (int) (Math.random()*NUM_SIDES) + 1;

}

}[code]

It keeps saying <identifier> expected on the Dice1.roll(); and the next 2 lines

ARGHH. Im new to java and i dont understand what im doing wrong
ps2cho is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:37 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC