Question

This is for a C# program. I would greatly appreciate any help! Thank you:)

For this assignment youre going to create a console application called A02PBallGenerator. This app is going to mimic a quick pick program in a lotto terminal. When the user runs your app youre going to select the numbers for them. Then you ask them if theyd like another set of numbers. Y for yes and N for No Use a do while loop so that if they type alowercase or uppercase y then you will give them a new set of numbers replacing the original ones. If they type anything else then exit the program. Powerball rules: In each game, players select five numbers from a set of 69 white balls and one number from 26 red Powerballs; the red ball number can be the same as one of the white balls. Your app is going to randomly choose five numbers from the white ball pool (1-69) and one from the red ball pool (1-26). Heres the catch, you cant repeat any of the white numbers. So if you find a duplicate then you have to keep choosing until you have a unique value. When you have your five unique values then Id like you to sort those values in ascending order. In other words, if your app chose 65, 2, 33, 14, 64 then you sort those so they show as 2, 14, 33, 64, 65. For the red ball you just randomly choose from 1-26 Here is a function that will return a number between (and including) the min and the max. So if you pass in 1 and 69 as arguments then youll get a number between (and including) 1 and 69 and youll get 1 to 26 (inclusive) if you pass in 1 and 26 for min and max. Leave the randomNumber declaration outside of the method. public static Random randomNumber new Random //Global, outside of any methods static int getRandomIntInclusive (int min, int max) return (randomNumber .Next (min max 1))

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;
using System.Linq;

public class Test
{
   public static Random randomNumber = new Random();
   static int getRandomIntInclusive(int min,int max)
   {
       return (randomNumber.Next(min,max+1));
   }
   public static void Main()
   {
       int[] whiteBalls = new int[5];
       int redBall ;
       char option = 'y';
      
       do //loop to generate white balls and red ball
       {
          
       for (int i = 0; i < 5; i++) //generate 5 red balls
       {
        int wBall;
      
        do   // do while loop to generate 5 white balls until the ball number is repeated
        {
            wBall = getRandomIntInclusive(1,69);        //1-69 for the white balls
        }while(whiteBalls.Contains(wBall)); //no duplicate values

        whiteBalls[i] = wBall;
       }
       Array.Sort(whiteBalls);   //sorting the generated numbers
       redBall = getRandomIntInclusive(1,26);
      
       Console.WriteLine("White Balls");
       for (int i = 0; i < 5; i++)
       Console.WriteLine(whiteBalls[i]); //display white balls
      
       Console.WriteLine("Red Ball");
       Console.WriteLine(redBall); //display red ball
      
       Console.WriteLine("Do you want to have another set of numbers?");
       option = Convert.ToChar(Console.Read());
       }while(option == 'Y' || option == 'y');
   }
}

Output:

White Balls
9
12
30
58
59
Red Balls
8
Do you want to have another set of numbers?y
White Balls
3
28
39
42
63
Red Balls
1
Do you want to have another set of numbers?n
Add a comment
Know the answer?
Add Answer to:
This is for a C# program. I would greatly appreciate any help! Thank you:) For this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that simulates playing the Powerball game. The program will generate random numbers...

    Write a C++ program that simulates playing the Powerball game. The program will generate random numbers to simulate the lottery terminal generated numbers for white balls and red Powerball. The user will have the option to self-pick the numbers for the balls or let the computer randomly generate them. Set the Grand Prize to $1,000,000,000.00 in the program. Project Specifications Input for this project: Game mode choice – self pick or auto pick Five numbers between 1 and 69 for...

  • c++ please help You are going to create a PowerBall Lottery game with functions. First, you...

    c++ please help You are going to create a PowerBall Lottery game with functions. First, you are going to generate 5 UNIQUE numbers between 1 and 69. Then you are going to generate the powerball number, which is a number between 1 and 26. Next you are going to ask the user for 5 numbers. Users should only be allowed to enter numbers in the range 1-69 for regular numbers, 1-26 for powerball pick. You will compare each of the...

  • Python code question - you are given the grand prize(in USD) and the winning numbers. Your...

    Python code question - you are given the grand prize(in USD) and the winning numbers. Your program will read multiple tickets (6 selected numbers in each ticket) from the input file. For each ticket, the program calculates its prize won, and outputs the prize (in USD) to the output file. How to Play the Game? In each ticket, the player selects five numbers from a set of 69 white balls (numbered 1 to 69) and one number from 26 red...

  • ASSIGNMENT 5 – POWERBALL SIMULATION Powerball® is a combined large jackpot game and a cash game. ...

    ASSIGNMENT 5 – POWERBALL SIMULATION Powerball® is a combined large jackpot game and a cash game. Every Wednesday and Saturday night at 10:59 p.m. Eastern Time, we draw five white balls out of a drum with 69 balls (1-69) and one red ball out of a drum with 26 red balls (1-26). Draw sales cut off at least 59 minutes before the draw. Check for local cut-off time. Players win by matching one of the 9 Ways to Win. The...

  • This question relates to pseudo random number generators. You will write a c program that pulls...

    This question relates to pseudo random number generators. You will write a c program that pulls the Powerball numbers. You will demonstrate how a deterministic number generator works.   In Powerball there are 5 white numbered balls that are pulled out of a drum containing 69 balls numbered 1-69. You cannot pull the same number twice. Additionally one red ball is numbered 1 to 26. You don’t have to worry about the PowerPlay option. A) Write a c program that simulates...

  • Please post screenshots only File Tools View CMSC 140 Common Projects Spring 2019(1) E - 3...

    Please post screenshots only File Tools View CMSC 140 Common Projects Spring 2019(1) E - 3 x Project Description The Powerball game consists of 5 white balls and a red Powerball. The white balls represent a number in the range of 1 to 69. The red Powerball represents a number in the range of 1 to 26. To play the game, you need to pick a number for each ball in the range mentioned earlier. The prize of winning the...

  • The Powerball lottery is played twice each week in 44 states, the District of Columbia, and the Virgin Islands. To play Powerball, a participant must purchase a $2 ticket, select five numbers from the digits 1 through 69, and then select a Powerball numbe

    The Powerball lottery is played twice each week in 44 states, the District of Columbia, and the Virgin Islands. To play Powerball, a participant must purchase a $2 ticket, select five numbers from the digits 1 through 69, and then select a Powerball number from the digits 1 through 26. To determine the winning numbers for each game, lottery officials draw 5 white balls out a drum of 69 white balls numbered 1 through 69 and 1 red ball out...

  • Please help to solve question 1 and subsections 1-4 1: Powerball Consider the multi-state lottery Powerball...

    Please help to solve question 1 and subsections 1-4 1: Powerball Consider the multi-state lottery Powerball game. Each ticket is $2 and allows a player to select 5 white balls from 1 to 69 (without replacement), and 1 Red Powerball, from 1 to 26. The order of the five white balls does not matter when evaluating a win. If there are 64 losing whiteball numbers, how many ways can the winner pick 4 of them. If the player is only...

  • The Powerball is played by selecting five numbers (without repetition) from the white balls labeled 1...

    The Powerball is played by selecting five numbers (without repetition) from the white balls labeled 1 through 69 (the order doesn't matter) and one red ball (the powerball) with label from 1 through 26. You win the grand prize if you get all five white numbers plus the powerball. 3. (a.) How many possible tickets are there? What is the probability of winning the grand prize? (b.) You win $4 if you get the powerball and at most one white...

  • need help editing or rewriting java code, I have this program running that creates random numbers...

    need help editing or rewriting java code, I have this program running that creates random numbers and finds min, max, median ect. from a group of numbers,array. I need to use a data class and a constructor to run the code instead of how I have it written right now. this is an example of what i'm being asked for. This is my code: import java.util.Random; import java.util.Scanner; public class RandomArray { // method to find the minimum number in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT