Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is the code which I have written for the user to play a round in a game until any of the player(s) reach 55.

Below is the code which I have written for the user to play a round in a game until any of the player(s) reach 55. I have got it work and roll the dice n times. However, instead of displaying a new dice value in the next round, I want the new dice value to be added to the dice value from previous round and then display the new value in next round.

using System; using System.Collections.Generic; using System.Linq; using System.Text;

namespace Space_Race { class Program { public static void Main() { double players = 0.0; string[] numbers = new string[] { "One", "Two", "Three", "Four", "Five", "Six" }; int square;

Console.Write("Welcome to the Space Race."); Console.Write(" This game is for 2 to 6 players."); Console.Write(" How many players (2-6): "); players = int.Parse(Console.ReadLine());

Console.WriteLine(" Press Enter to play a round ..."); Console.ReadLine();

Console.WriteLine("First Round"); Console.Write(" "); bool gameFinish = false;

while (!gameFinish) { Random random = new Random(); int dice_1, dice_2; int diceValue;

square = 0; for (int i = 0; i < players; i++) { diceValue = 0; dice_1 = random.Next(1, 7); dice_2 = random.Next(1, 7); diceValue = diceValue + dice_1 + dice_2;

System.Console.WriteLine(numbers[i] + " on square " + diceValue); } diceValue = square; dice_1 = random.Next(1, 7); dice_2 = random.Next(1, 7); diceValue = diceValue + dice_1 + dice_2;

Console.WriteLine("Press Enter to play a round ..."); Console.ReadLine(); Console.WriteLine("Next Round");

}

}

} }

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_2

Step: 3

blur-text-image_3

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 SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

1. Who is responsible for resolving this dilemma?

Answered: 1 week ago

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago