Question

In: Computer Science

Lets make a Deal c# simulation? The steps that you will need to complete this homework...

Lets make a Deal c# simulation?

The steps that you will need to complete this homework is:

//display and output to the screen telling the player that they can win a car with exactly $1000

//simulate the rolling of the die for $100, $200 or $300

//show the player the amount they have just rolled

//show the player their total amount

//check if total amount has not exceeded $1000. If exceeded, game over (tell player they lost)

//if total is exactly $1000, game over, tell they won a new car!

//ask the player if they want to keep rolling or take the money

      //if keep the money, showing output to the screen showing the amount they have won

      //if keep rolling, go back to step two

Solutions

Expert Solution

C# PROGRAM:

OUTPUT SNAPSHOTS:

TEXT CODE:

using System;
class HelloWorld {
static void Main() {
// Declaration of variable to store total amount
int totalAmount = 0;
// Declaration of integer array to store die value
int[] dieValue = {100, 200, 300};
/* Displaying and output to the screen telling the player that they can win a car with exactly $1000 */
Console.WriteLine("You can win a car with exactly $1000\n");
  
do{
Console.WriteLine("\nPress Enter to Roll the die...");
Console.ReadLine();
  
/* Simulating the rolling of the die for $100, $200 or $300 */
Random randObj = new Random(); // Creating object of Random class
int randValue= randObj.Next(3); // Generating random number between 0 to 2
// Adding the rolled die value to the total amount
totalAmount = totalAmount + dieValue[randValue];
/* Showing the player the amount they have just rolled */
Console.WriteLine("Rolled Dice Value :$" + dieValue[randValue]);
/* Showing the player their total amount */
Console.WriteLine("Total Amount :$" + totalAmount);
  
/* Check if total amount has not exceeded $1000. If exceeded, game over (telling player they lost) */
if(totalAmount>1000){
Console.WriteLine("Ouch.. You Lost, Total Amount exceeded $1000");
}else if (totalAmount==1000){ /* if total is exactly $1000, game over, telling they won a new car! */
Console.WriteLine("Congratulations!, You won a new car.");
}
  
if(totalAmount>=1000){
/* Asking the player if they want to keep rolling or take the money */
Console.WriteLine("Do you want to keep the money or Keep Rolling?");
Console.WriteLine("Enter 1 for Keeping Money");
Console.WriteLine("Enter 2 for Keep Rolling");
// Storing user input in userSelection variable
string userSelection = Console.ReadLine();
  
/* if keep the money, showing output to the screen showing the amount they have won */
if(userSelection=="1"){
Console.WriteLine("\nYou won total amount of $"+totalAmount);
break;
} else if(userSelection=="2"){ /* if keep rolling, go back to step two */
totalAmount = 0;
} else{
Console.WriteLine("\nInvalid Input!");
}
}
}while(totalAmount<1000);
  
}
}

EXPLANATION:

  • Please refer to program comments for understanding purposes.

Related Solutions

For this homework we are going to walk you through creating a class. Lets look at...
For this homework we are going to walk you through creating a class. Lets look at a pizza restaurant and create a class for this. We will call our class pizza. The goal for every class is to include everything that has to happen for that class in 1 place. So whenever we create a class we need to think of what the nouns or variables will be for that class and then what the actions or methods will be...
Follow the steps below to complete your SPSS homework assignment: At the bottom of this document...
Follow the steps below to complete your SPSS homework assignment: At the bottom of this document are 20 questionnaires that were completed by undergraduate students at University XYZ. Open a new SPSS file and save it. Leave the output window open. You will save the output in just a moment. Use the questionnaire questions to correctly define each variable in an SPSS file. Further directions can be found at the following YouTube link: https://www.youtube.com/watch?v=MoKDcPpRa_0 Generate a “file information” output of...
To each part of the homework problems, make a complete problem statement and then show your...
To each part of the homework problems, make a complete problem statement and then show your work for each solution with detailed steps, otherwise, your solution will receive a grade zero, even if it is correct.    Suppose you are told that independent random variables X and Y each have a uniform density on {1,2,…,N}. List explicitly, in terms of N, the elements (x,y) of (X,Y) and then, write down the joint density function density Pr (X=x, Y=y) List the...
does students benefit from homework ? i need you make me annotated biblography on this topic
does students benefit from homework ? i need you make me annotated biblography on this topic
Lets try this again...(if you were able to complete this assignment, then complete the Unit 1's...
Lets try this again...(if you were able to complete this assignment, then complete the Unit 1's replacement of this) You are the human resource director for a company of 10,000 employees specializing in the production of swimming products. Due to the increased complexity of the manufacturing process, you are interested in improving the basic skills (e.g., math, reading, writing) of your employees. Two methods look promising—one involving web-based training and the other involving the use of workbooks. The web-based approach...
I need a c# console program that lets a player choose to play poker or black...
I need a c# console program that lets a player choose to play poker or black jack against the computer.
Discuss the steps you would need to take in order to make your practicum classroom a...
Discuss the steps you would need to take in order to make your practicum classroom a STEM learning environment. Support your steps with research.
Complete a CARE PLAN for a Muslim with Spiritual and religious need. The six steps of...
Complete a CARE PLAN for a Muslim with Spiritual and religious need. The six steps of the nursing process required 1- assessment 2- diagnosis 3- outcome identification 4- planning 5- implementation 6- and evaluation Nursing diagnose approved by NANDA International http://www.nanda.org/ Include a list of all references used to support your answer.
Complete a CARE PLAN for the client with Spiritual and religious need. The six steps of...
Complete a CARE PLAN for the client with Spiritual and religious need. The six steps of the nursing process required 1- assessment 2- diagnosis 3- outcome identification 4- planning 5- implementation 6- and evaluation Nursing diagnose approved by NANDA International http://www.nanda.org/ Include a list of all references used to support your answer.
Complete a CARE PLAN for the client with Spiritual and religious need. The six steps of...
Complete a CARE PLAN for the client with Spiritual and religious need. The six steps of the nursing process required 1- assessment 2- diagnosis 3- outcome identification 4- planning 5- implementation 6- and evaluation Thats question
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT