To illustrate random variables, create a program for a simple game. Below are the steps of the simple game:1. User inputs a bet2. User inputs guess of the total of two numbers (from XXXXXXXXXXClicks...

1 answer below »
To illustrate random variables, create a program for a simple game. Below are the steps of the simple game:1. User inputs a bet2. User inputs guess of the total of two numbers (from 2-20)3. Clicks button A (generates any value from 1-10)4. Clicks button B (generates any value from 1-10)5. If the total of the two numbers is the same as the user’s guess, user wins and gets twice his/her bet otherwise pays the bet.6. User may choose to play again otherwise exits.7. Provide a summary of the user’s game.
Answered 1 days AfterFeb 05, 2021

Answer To: To illustrate random variables, create a program for a simple game. Below are the steps of the...

Aditya answered on Feb 07 2021
151 Votes
import java.util.ArrayList;
import java.util.Scanner;
public class Game {
    public static void mai
n(String[] args) {
        Scanner scanner = new Scanner(System.in);
        float bet;
        int guess;
        int number1;
        int number2;
        ArrayList betList = new ArrayList();
        ArrayList guessList = new ArrayList();
        ArrayList number1List = new ArrayList();
        ArrayList number2List = new ArrayList();
        String repeat = "Y";
        do
        {
            System.out.print("Enter bet: ");
            bet = scanner.nextFloat();
            guess = getNumber();
         number1 = (int) ((Math.random() * (9)) + 1);
         number2 = (int) ((Math.random() * (9)) + 1);
         int sum = number1+number2;
         System.out.print("\n\nNumber 1: "+number1);
         System.out.print("\nNumber 2: "+number2);
         System.out.print("\nSum:...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here