Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help getting this code to run without any errors. Please use copyable link so I can test. Here is the code in C#: /**

Need help getting this code to run without any errors. Please use copyable link so I can test.

Here is the code in C#:

/**

* Workshop 5

*

* This program simulates 10,000 games of craps.

* It counts the number of wins and losses and outputs the probability

* of winning.

*

* Created: NA

*

* @author NA

* @version 1

*/

public class Craps

{

private static readonly int NUM_GAMES = 100;

public static void Main()

{

System.String playAgain = "";

do{

// Variable declarations

int numSevens = 0;

int numElevens = 0;

int roll = 0;

// Play 100 games

Random.rand = new Random();

for (int i=0; i

{

// Simulate rolling the two dice, with values from 1-6

roll = rand.Next(6) + rand.Next(6) + 2;

// Check for initial win or loss

if (roll == 7)

{

numSevens++;

}

else

if(roll == 11)

{

numElevens++;

}

}

// Output probability of winning

System.Console.WriteLine("The player rolled {0} sevens and {1} elevens for a total of {2} wins out of 100.",numSevens,numElevens,(numSevens + numElevens));

System.Console.WriteLine(" Try again, Enter y for yes, n for no");

playAgain = Console.ReadLine();

}while(playAgain.Equals("y", StringComparison.InvariantCultureIgnoreCase)); } } // Question 2

Here's the error report:

Build Failed. Please correct the errors and try again

6 Errors

Lines:

52

60

94

98

(

error CS0103: The name 'StringComparison' does not exist in the current context

error CS0103: The name 'Random' does not exist in the current context

error CS0246: The type or namespace name 'Random' could not be found (are you missing a using directive or an assembly reference?)

error CS0103: The name 'rand' does not exist in the current context

error CS0103: The name 'rand' does not exist in the current context

error CS0103: The name 'Console' does not exist in the current context)

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions