Question: In C#, please add comments so I can better understand the content. This program must simulate a Magic 8-Ball. The Magic 8-Ball is a fortune
In C#, please add comments so I can better understand the content.
This program must simulate a Magic 8-Ball. The Magic 8-Ball is a fortune telling toy in which the player asks any Yes/No question and the Magic 8-Ball randomly answers the question with one of 20 possible answers For this program, you only need to use the following 5 answers: >It is certain >Reply hazy, Try Again >Dont count on it >Signs point to yes >My sources say no. Be sure to use IF and IF ELSE statements for it. Use this random number generator code for the program Random rnd = new Random(); int roll = rnd.Next(0,5);
This is what I have so far.
using System; namespace 8ball { public class 8_Ball { public static void Main() { Console.WriteLine("Enter a yes/no question you want to ask"); string ques = Console.ReadLine(); string[] possible_answers = new string[5]{"It is certain", "Reply hazy, Try Again" , "Dont count on it", "Signs point to yes", "My sources say no"}; Random rnd = new Random(); int roll = rnd.Next(0, 5); Console.WriteLine("Answer : {0}", possible_answers[roll]); Console.ReadLine(); } } } -Thank You!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
