# Problem with int and formula

Page 1 of 1

## 3 Replies - 368 Views - Last Post: 08 February 2013 - 08:02 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=311630&amp;s=79e7398c467d21792d03660418c023a2&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ct1031

Reputation: 0
• Posts: 1
• Joined: 08-February 13

# Problem with int and formula

Posted 08 February 2013 - 03:02 PM

hello
I am new to coding....
I am creating a app to play craps..roll the dice
I am having trouble generating the integer range and when I get to the formula it states "the bad operand types for binary operator '+''

int [] dice1={1,2,3,4,5,6};
int[] dice2={1,2,3,4,5,6};

int Roll1(){
int Value=(dice1)+(dice2); //this is where the error is
return Value;
}
it suppose to be random rolls with the options between 1 and 6
I know that I have to use the new java.util.Random() I have not done that yet..

Is This A Good Question/Topic? 0

## Replies To: Problem with int and formula

### #2 GregBrannon

• D.I.C Lover

Reputation: 2250
• Posts: 5,340
• Joined: 10-September 10

## Re: Problem with int and formula

Posted 08 February 2013 - 03:07 PM

dice1[] and dice2[] are integer arrays. To reference the arrays (pass to methods, etc.) you use the array name by itself, like "dice1" and "dice2". dice1 and dice2 can't meaningfully be added together as you're showing:

int Value=(dice1)+(dice2);

at least not as an integer value, but I'm not sure why you'd want to do that as any type.

What are you trying to do with that statement?

This post has been edited by GregBrannon: 08 February 2013 - 03:08 PM

### #3 flaminsnowman99

Reputation: 3
• Posts: 45
• Joined: 15-December 12

## Re: Problem with int and formula

Posted 08 February 2013 - 04:41 PM

One thing you could do is...
```Random rad = new Random();
int dice1, dice2, diceTotal;

diceTotal = dice1 + dice2;
```

This saves you the trouble of using arrays and in my opinion makes the programs simpler.

### #4 natecat

Reputation: 56
• Posts: 233
• Joined: 19-December 11

## Re: Problem with int and formula

Posted 08 February 2013 - 08:02 PM

flaminsnowman99, on 08 February 2013 - 11:41 PM, said:

One thing you could do is...
```Random rad = new Random();
int dice1, dice2, diceTotal;