Hey guys,

I'm working on this program. It should roll 2 separate die and repeats until the computer rolls doubles.

I'm having some issues with it and could use some help.

// RollDoubles.java
// 

import java.util.Scanner;
public class RollDoubles

{
    // Dice roll repeatedly until computer rolls doubles
    // print each die's value
    
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        // Roll the dice.
        
        int die1, die2;
        int rollcount;
        boolean rolledDoubles = false; // haven't rolled doubles
        
        rollcount = 0;
        while(die1!=die2)
        {
         die1 = rollDie();
         die2 = rollDie();
         
         if(die1==die2)
         rolledDoubles = true; //stops loop
            
            System.out.println("Die1= "+die1+" and Die2= "+die2);
            
            rollcount++;
        }
        System.out.println("It took "+rollcount+" rolls to get doubles.");

    }
    
    
    // Does the math
    
    public static String rollDie()
    {
            
        int dieRoll = (int)(Math.random()*6)+1;
        
        return dieRoll;
        
    }
        
}

here are the erros:

RollDoubles.java:24: incompatible types
found : java.lang.String
required: int
die1 = rollDie();
^
RollDoubles.java:25: incompatible types
found : java.lang.String
required: int
die2 = rollDie();
^
RollDoubles.java:46: incompatible types
found : int
required: java.lang.String
return dieRoll;
^
3 errors

----jGRASP wedge: exit code for process is 1.
----jGRASP: operation complete.

All help is appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.