I have NO idea how to do this. I'm thinking I'm supposed to assign each word with that number, but I don't know how to do that (if at all possible) I've posted my code below. We've gone over classes, if statements and loops. We'v yet to cover arrays, so that isn't an option for me right now.
public class Slots
{
public static void main(String[] args)
{
// Creating a Scanner object
Scanner input = new Scanner(System.in);
// Declare my variables as INTs
int won = 0, bet = 0, totalBet = 0, totalWon = 0, counter = 0;
// Declare my slots as INTs
int num1, num2, num3;
// Ask user how much they'd like to bet.
System.out.println("How much would you like to bet? Bet 0 if " +
"you wish to walk away.");
bet = input.nextInt();
// While loop
while (bet != 0)
{
totalBet += bet;
totalWon += won;
// Create Random objct
Random randomNumbers = new Random();
num1 = randomNumbers.nextInt(5);
num2 = randomNumbers.nextInt(5);
num3 = randomNumbers.nextInt(5);
// Show the numbers
System.out.println("The three are " + num1 + " " + num2 +
" " + num3 + " " );
// If statement to decide if they won
if ((num1 != num2 && (num1 != num3)))
{
System.out.println("Sorry you didn't win.");
}
else if (num1 == num2 && num1 == num3)
{
won = bet * 3;
System.out.println("You won " + (bet * 3));
}
else
{
System.out.println("You won " + (bet * 2));
won = bet * 2;
}
// Ask user how much they'd like to bet.
System.out.println("How much would you like to bet? Bet 0 if" +
"you wish to walk away.");
bet = input.nextInt();
}
//Display totals
System.out.println("Your total winnings are, " + totalWon +
" and your total bets were " + totalBet + ".");
}
}
Help is greatly appreciated folks!

New Topic/Question
Reply



MultiQuote




|