Question

In: Computer Science

Using c# programming language Write a program that mimics a lottery game. Have the user enter...

Using c# programming language Write a program that mimics a lottery game. Have the user enter 3 distinct numbers between 1 and 10 and match them with 3 distinct, randomly generated numbers between 1 and 10. If all the numbers match, then the user will earn $10, if 2 matches are recorded then the user will win $3, else the user will lose $5. Keep tab of the user earnings for, let say 5 rounds. The user will start with $25.

Solutions

Expert Solution

Solution:

Code:

Output:

Copyable Code:

using System;

//Main class

class MainClass {

//Main method

public static void Main (string[] args) {

//Declaration of variables

int number1,number2,number3;

int rand1,rand2,rand3;

int amount =25;

int i=1;

//Loop

do

{

//Get values

Console.WriteLine ("Enter 3 numbers between 1 and 10:");

Console.WriteLine("Enter the value of number1:");

number1=Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter the value of number2:");

number2=Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter the value of number3:");

number3=Convert.ToInt32(Console.ReadLine());

//Validation

if(number1>10 || number1<1)

{

Console.WriteLine("Renter the value of number1:");

number1=Convert.ToInt32(Console.ReadLine());

}

if(number2>10 || number2<1)

{

Console.WriteLine("Renter the value of number2:");

number2=Convert.ToInt32(Console.ReadLine());

}

if(number2>10 || number2<1)

{

Console.WriteLine("Renter the value of number1:");

number1=Convert.ToInt32(Console.ReadLine());

}

//Generate random values

Random r=new Random();

rand1=r.Next(1,10);

rand2=r.Next(1,10);

rand3=r.Next(1,10);

//Check with lottory values

if(number1==rand1 && number2==rand2 && number3==rand3)

{

Console.WriteLine ("Congrats!!Won on the lottery");

Console.WriteLine("Got $10");

amount=amount+10;

}

else if((number1==rand1 && number2==rand2)||(number2==rand2 && number3==rand3)||(number3==rand3 && number1==rand1))

{

Console.WriteLine("Got $3");

amount=amount+3;

}

else{

Console.WriteLine("You lose the game");

amount=amount-5;

}

i=i+1;

}while(i<=5);

Console.WriteLine("Your final amount is:"+amount);

}

}


Related Solutions

Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
Using C# programming language, Write a program that sort three numbers entered by the user using...
Using C# programming language, Write a program that sort three numbers entered by the user using only if and nested if statements. If for instance the user entered 5, 2, and 7; the program should display 2,5,7.
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
Write a program in C that lets the user enter a message using SMS Language(e.g. lol,...
Write a program in C that lets the user enter a message using SMS Language(e.g. lol, omg, omw etc.), then translates it into English (e.g. laughing out loud, oh my god, on my way etc.). Also provide a mechanism to translate text written in English into SMS Language. needs to be able to translate at least 10 sms words
Programming Language: C++ Overview For this assignment, write a program that will simulate a single game...
Programming Language: C++ Overview For this assignment, write a program that will simulate a single game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the dice is equal to 7 or 11, the player wins immediately....
C programming. Write a program that prompts the user to enter a 6x6 array with 0...
C programming. Write a program that prompts the user to enter a 6x6 array with 0 and 1, displays the matrix, and checks if every row and every column have the even number of 1’s.
In C++, Write the following program using a vector: A common game is the lottery card....
In C++, Write the following program using a vector: A common game is the lottery card. The card has numbered spots of which a certain number are selected at random. Write a Lotto() function that takes two arguments. The first should be the number of spots on a lottery card and the second should be the number of spots selected at random. The function should return a vector object that contains, in sorted order, the numbers selected at random. Use...
Using (C programming language) Create a health monitoring program, that will ask user for their name,...
Using (C programming language) Create a health monitoring program, that will ask user for their name, age, gender, weight, height and other health related questions like blood pressure and etc. Based on the provided information, program will tell user BMI, blood pressure numbers if they fall in healthy range or not and etc. Suggestions can be made as what should be calorie intake per day and the amount of exercise based on user input data. User should be able to...
Write a program in c++ using only if statements that prompts the user to enter an...
Write a program in c++ using only if statements that prompts the user to enter an integer for today’s day of the week (Sunday is 0, Monday is 1 …., and Saturday is 6) then displays today. Also, prompt the user to enter the number of days after today for a future day and display the future day of the week. The future day can be computed as follows: (today + number of days after today) % 7 Sample run...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library and dynamic memory(malloc) that multiplies two matrices together. The numbers in the matrices must be read in from a text file. The program should also check if the two matrices are capable of being multiplied together. The amount of threads used has to be dynamic. The user should be able to choose how many threads they wish to use using the command line. Finally,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT