Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 CIT 143: C# I Final Program Worth 300 points This assignment is worth 300 points. If the program compiles, and follows the directions completely,

1 CIT 143: C# I Final Program Worth 300 points

This assignment is worth 300 points. If the program compiles, and follows the directions completely, you will receive the entire 300 points, as long as all files are submitted. Below is a list of what must be included. Partial credit is given only if the directions have been followed completely (this includes programs that do not successfully compile).

In this assignment you will create a console application. This program will allow you to select Powerball numbers. For the first 5 numbers you will be requested to enter a number that is greater than zero and less than 70 since the first 5 numbers on the Powerball lottery must be between1-69. However, theres a catch! Each of these five numbers must be different.

You must also generate the winning numbers. The first five winning numbers must be stored within a second array. Generate the numbers by creating a Random object. Follow these steps in order to accomplish this:

Create a Random object by: private Random number = new Random();

Within a separate method you want to generate the winning numbers and return the value. In the following code I returned an array named winningNumbers. I also created two constants, the first sets the maximum value of 69 and the second a maximum value of 26. The method is written as:

public int[] GetWinningNumbers() {

for (int i = 0; i < winningNumbers.Length; i++)

{ winningNumbers[i] = number.Next(MAXIMUM);

for (int j = 0; j < winningNumbers.Length; j++)

{ if (winningNumbers[i] == winningNumbers[j] && j != i)

{ winningNumbers[i] = number.Next(MAXIMUM);

}

}

}

return winningNumbers;

}

The powerball number would repeat if the number entered is less than 1 or greater than 26. When any of the first five numbers entered is less than 0 or greater 69 the user will receive a message to this effect and will be asked to reenter the number. You will create the code that will display one message when a number that is less than 1 is entered and a different message will display when the number entered is greater than 69, as shown in the above examples. If the number is the same as any number entered before it (with the exception of the Powerball number, which is the last number entered) the user will receive a message to this effect and will be requested to reenter the number. This is the same for the second through fifth numbers. When entering the Powerball number, if the number entered IS NOT between 0 and 26, the user will receive a message to this effect and asked to reenter the number. One message will display if the number entered is less than 1, and a different message if the number entered is greater than 26. The following MUST be included in the program:

You must have multiple classes. One class must include the accessor/mutator methods, a ReadInput() method and a WriteOutput() method. Name this first program Powerball.

The values of the first five numbers must be saved within an array. The first element of the array will equal the first number entered, the second element of the array will equal the second number entered, etc. However, the number entered is not to be added to the array unless it is both unique from the other numbers entered, and it also falls within the correct range of numbers.

The second program is to be named PowerballTest and will be responsible for creating a Powerball object and invoking the ReadInput() and WriteOutput() methods located in the Powerball class. Remember that within Visual Studio you will create a Console Application when creating your project. This will contain the Main() method. The Main() method is to contain Only a Powerball object and call the ReadInput() and WriteOutput() 5 methods for that object. It is to contain no other code. Points will be deducted if it contains anything but this bit of code. The Powerball class will have the majority of the code.

You must have the first five winning numbers saved within an array.

You must create a Random object in order to generate the winning numbers.

This is all in C#.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions