• 1.5k
• 28
• 16k

# Create a console-based lottery game application - Help needed by anyone

Aug 10 2012 1:44 PM

1.       Create a console-based lottery game application. Generate three random numbers, each between 1 and 4. Allow the user to guess three numbers. Compare each of the user's guesses to the three random numbers and display a message that includes the user's guess, the randomly deter-mined three-digit number, and the amount of money the user has won as follows:

Matching Numbers                                        Award (\$)

Any one matching                                           10

Two matching                                                 100

Three matching, not in order                      1000

Three matching in exact order                   10,000

No matches                                                        0

Make certain that your application accommodates repeating digits. For example, if a user guesses 1, 2, and 3, and the randomly generated digits are 1, 1, and 1, do not give the user credit for three correct guessesâ€”just one. Save the file as Lottery.cs.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Errors :  program work but give me different result ... i want result as above mansion in question help me its my 1st Question on this great  website

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace random

{

class Program

{

static void Main(string[] args)

{

// declaring integers

int iNum1;

int iNum2;

int iNum3;

int iCount = 0;

int iGuess;

int iRandom;

int iAmount;

// declaring constants

const int iBALLS = 3;

const int iMATCHONE = 10;

const int iMATCHTWO = 100;

const int iMATCHTHREE = 1000;

const int iMATCHFOUR = 10000;

// array

// generating random numbers

Random randomnumber = new Random();

iNum1 = randomnumber.Next(1, 4);

iNum2 = randomnumber.Next(1, 4);

iNum3 = randomnumber.Next(1, 4);

iRandom = iNum1 + iNum2 + iNum3 ;

for (iCount = 0; iCount < iBALLS; iCount++)

{

Console.Write("\nNo:" + (iCount + 1) + " Choose your number: ");

while (iGuess < 1 || iGuess > 4)

{

Console.WriteLine("You have entered an incorrect number please try again");

}

iAmount = 0;

if (iGuess == iNum1)

{

Console.WriteLine("you won \$" + iMATCHONE);

Console.WriteLine();

//Console.WriteLine("Press any key to continue");

iAmount++;

}

if (iGuess == iNum2)

{

Console.WriteLine("you won \$" + iMATCHTWO);

Console.WriteLine();

//Console.WriteLine("Press any key to continue");

iAmount++;

}

if (iGuess == iNum3)

{

Console.WriteLine("you won \$" + iMATCHTHREE);

Console.WriteLine();

//Console.WriteLine("Press any key to continue");

iAmount++;

}

if (iGuess == iNum1 && iGuess == iNum2 && iGuess == iNum3)

{

Console.WriteLine("you won \$" + iMATCHFOUR);

Console.WriteLine();

//Console.WriteLine("Press any key to continue");

iAmount++;

}

Console.WriteLine("you have matched " + iAmount + " numbers");

}

Console.WriteLine("The numbers are " + iNum1 + ", " + iNum2 + ", " + iNum3 + ", ");