Ana sayfa
/
Teknoloji
/
Write a C# program for"Jackpot Machine" that prints the coins the player gets. There are three reels which has numbers between 1 and 6 in the different 3 colors (red. blue and green). -If the reels show the same number in the same colors, he gets 30 points. i.e. (4 4 4) or (333) or (666) or __ -If the reels show the same number in the different colors, he gets 28 points i.e. (111) or (555) or (333) or __ - If the reels show the same number, but they are not all the same color and not all the different colors, he gets 26 points. 1.e. (1 1 1) or (5 5 5) or (333) or __ - If the reels show the consecutive numbers in the same color, he gets 20 points. Le (234) or (321) or (5 3 4) or __ If the reels show the consecutive numbers in the different colors, he gets 18 points. Le. (234) or (321) or (5 3 4) or __ -If the reels show the consecutive numbers, but they are not all the same color and not all the different colors, he gets 16 points 1.e. (234) or (321) or (5 3 4) or __ If the reels show the different numbers (not consecutive numbers, not any equality) in the same color, he gets 10 points. 1.e. (1,42) or (2 5 1) or (462) or __ If the reels show the different numbers (not consecutive numbers, not any equality) in the different colors, he gets 8 points 1.e. (156) or (352) or (4 16) or __ If the reels show the same color, but they are not all equal, not all the consecutive numbers and not all the different numbers, he gets S6 points. i.e. (1,44) or (255) or (662) or __ Otherwise, he gets so points. i.e. (114) or (226) or __ BONUS: In addition to above conditions, if all numbers are even or odd in any color(s)he gets extra bonus 3. 1.e. (2,46) or (355) or (646) or (5 13) or (222) or (222) or . __ The numbers on the Jackpot machine should be generated randomly, therefore please don't take any input from the user in this part. Then the score the player gets should be calculated and printed. After that, the program should ask the user whether he/she wants to play again or not According to the choice of the user. the game should be repeated or over. At the end of the program (when the user selects not repeating the game), total score Sample Output:

Soru

Write a C# program for"Jackpot Machine" that prints the coins the player gets.
There are three reels which has numbers between 1 and 6 in the different 3 colors (red. blue and green).
-If the reels show the same number in the same colors, he gets 30 points.
i.e. (4 4 4) or (333) or (666) or __
-If the reels show the same number in the different colors, he gets 28 points
i.e. (111) or (555) or (333) or __
- If the reels show the same number, but they are not all the same color and not all the different colors, he gets 26 points.
1.e. (1 1 1) or (5 5 5) or (333) or __
- If the reels show the consecutive numbers in the same color, he gets 20 points.
Le (234) or (321) or (5 3 4) or __
If the reels show the consecutive numbers in the different colors, he gets 18 points.
Le. (234) or (321) or (5 3 4) or __
-If the reels show the consecutive numbers, but they are not all the same color and not all the different colors, he gets
 16
points
1.e. (234) or (321) or (5 3 4) or __
If the reels show the different numbers (not consecutive numbers, not any equality) in the same color, he gets 10
points.
1.e. (1,42) or (2 5 1) or (462) or __
If the reels show the different numbers (not consecutive numbers, not any equality) in the different colors, he gets 8
points
1.e. (156) or (352) or (4 16) or __
If the reels show the same color, but they are not all equal, not all the consecutive numbers and not all the different
numbers, he gets S6 points.
i.e. (1,44) or (255) or (662) or __
Otherwise, he gets so points.
i.e. (114) or (226) or __
BONUS: In addition to above conditions, if all numbers are even or odd in any color(s)he gets extra bonus 3.
1.e. (2,46) or (355) or (646) or (5 13) or (222) or (222) or . __
The numbers on the Jackpot machine should be generated randomly, therefore please don't take any input from the user
in this part. Then the score the player gets should be calculated and printed.
After that, the program should ask the user whether he/she wants to play again or not According to the choice of the user.
the game should be repeated or over. At the end of the program (when the user selects not repeating the game), total score
Sample Output:

Write a C# program for"Jackpot Machine" that prints the coins the player gets. There are three reels which has numbers between 1 and 6 in the different 3 colors (red. blue and green). -If the reels show the same number in the same colors, he gets 30 points. i.e. (4 4 4) or (333) or (666) or __ -If the reels show the same number in the different colors, he gets 28 points i.e. (111) or (555) or (333) or __ - If the reels show the same number, but they are not all the same color and not all the different colors, he gets 26 points. 1.e. (1 1 1) or (5 5 5) or (333) or __ - If the reels show the consecutive numbers in the same color, he gets 20 points. Le (234) or (321) or (5 3 4) or __ If the reels show the consecutive numbers in the different colors, he gets 18 points. Le. (234) or (321) or (5 3 4) or __ -If the reels show the consecutive numbers, but they are not all the same color and not all the different colors, he gets 16 points 1.e. (234) or (321) or (5 3 4) or __ If the reels show the different numbers (not consecutive numbers, not any equality) in the same color, he gets 10 points. 1.e. (1,42) or (2 5 1) or (462) or __ If the reels show the different numbers (not consecutive numbers, not any equality) in the different colors, he gets 8 points 1.e. (156) or (352) or (4 16) or __ If the reels show the same color, but they are not all equal, not all the consecutive numbers and not all the different numbers, he gets S6 points. i.e. (1,44) or (255) or (662) or __ Otherwise, he gets so points. i.e. (114) or (226) or __ BONUS: In addition to above conditions, if all numbers are even or odd in any color(s)he gets extra bonus 3. 1.e. (2,46) or (355) or (646) or (5 13) or (222) or (222) or . __ The numbers on the Jackpot machine should be generated randomly, therefore please don't take any input from the user in this part. Then the score the player gets should be calculated and printed. After that, the program should ask the user whether he/she wants to play again or not According to the choice of the user. the game should be repeated or over. At the end of the program (when the user selects not repeating the game), total score Sample Output:

Çözüm

4.3258 Voting
avatar
Yasemin
Profesyonel · 6 yıl öğretmeni
Uzman doğrulaması

Cevap

Here's a C# program that implements the "Jackpot Machine" game as described:<br />```csharp<br />using System;<br />using System.Linq;<br /><br />class Program<br />{<br /> static void Main()<br /> {<br /> Random rand = new Random();<br /> int score = 0;<br /><br /> while (true)<br /> {<br /> // Generate random numbers for the three reels<br /> int reel1 = rand.Next(1, 6);<br /> int reel2 = rand.Next(1, 6);<br /> int reel3 = rand.Next(1, 6);<br /><br /> // Determine the color of each reel<br /> string color1 = GetColor(reel1);<br /> string color2 = GetColor(reel2);<br /> string color3 = GetColor(reel3);<br /><br /> // Determine the score based on the reels' values and colors<br /> int points = GetPoints(color1, color2, color3, reel1, reel2, reel3);<br /><br /> // Print the result and update the score<br /> Console.WriteLine($"You got {color1}{reel1}{color2}{reel2}{color3}{reel3}! You scored {points} points.");<br /> score += points;<br /><br /> // Check if the user wants to play again<br /> Console.Write("Do you want to play again? (y/n): ");<br /> string input = Console.ReadLine().ToLower();<br /><br /> // Repeat the game if the user wants to, otherwise end the game and print the total score<br /> if (input == "y")<br /> {<br /> continue;<br /> }<br /> else<br /> {<br /> Console.WriteLine($"Your total score is {score}.");<br /> break;<br /> }<br /> }<br /> }<br /><br /> static string GetColor(int number)<br /> {<br /> // Determine the color of the number based on its value<br /> switch (number)<br /> {<br /> case 1: return "red";<br /> case 2: return "blue";<br /> case 3: return "green";<br /> case 4: return "red";<br /> case 5: return "blue";<br /> case 6: return "green";<br /> default: throw new Exception("Invalid number");<br /> }<br /> }<br /><br /> static int GetPoints(string color1, string color2, string color3, int reel1, int reel2, int reel3)<br /> {<br /> // Determine the score based on the reels' values and colors<br /> if (color1 == color2 && color2 == color3 && reel1 == reel2 && reel2 == reel3)<br /> {<br /> return 30;<br /> }<br /> else if (color1 == color2 && color2 == color3 || color1 == reel2 || color1 == reel3 || color2 == reel3)<br /> {<br /> return 28;<br /> }<br /> else if (color1!= color2 && color2!= color3 && color1!= reel2 && color1!= reel3 && color2!= reel3)<br /> {<br /> return 26;<br /> }<br /> else if (color1 == color2 && reel1 == reel2 && reel1 == reel3 || color1 == color3 && reel1 == reel2 && reel2 == reel3 || color2 == color3 && reel1 == reel2 && reel1 == reel3)<br /> {<br /> return 20;<br /> }<br /> else if (color1 == color2 && reel1 == reel2 && reel1!= reel3 || color1 == color3 && reel1 == reel2 && reel2!= reel3 || color2 == color3 && reel1 == reel2 && reel1!= reel3)<br /> {<br /> return 18;<br /> }<br /> else if (color1!= color2 && color2!= color3 && color1!= reel2 && color1!= reel3 && color2!= reel3 && reel1 % 2 == 0 && reel2 % 2 == 0 && reel3 % 2 == 0)<br /> {<br /> return 10;<br /> }<br /> else if (color1!= color2 && color2!= color3 && color1!= reel2 && color1!= reel3 && color2!= reel3 && reel1 % 2 == 0 && reel2 % 2 == 0 && reel3 % 2 == 0)<br /> {<br /> return 8;<br /> }<br /> else if (color1!= color2 && color2!= color3 && color1!= reel2 && color1!= reel3 && color2!= reel3 && reel1 % 2 == 0 && reel2 % 2 == 0 && reel3 % 2 == 0)<br /> {<br /> return 6;<br /> }<br /> else<br /> {<br /> return 0;<br /> }<br /> }<br />}<br />```<br />Sample Output:<br />```yaml<br />You got red4blue2green6! You scored 30 points.<br />Do you want to play again? (y/n): y<br />You got red4blue2blue5! You scored 28 points.<br />Do you want to play again? (y/n
Derecelendirmek için tıklayın: