0

Problem solving in C#

I have a problem in this code i can’t get output I want in this code need get to string form user then using random in c# for select number after get to number from player in console when the number player input equal number random should say Congratulations when wrong say Faild Using for loop this is my attempts:

22nd Mar 2022, 11:38 AM
Arazdeary
Arazdeary - avatar
5 Respuestas
+ 1
You're missing a semicolon at the end of line 4. That's it?
22nd Mar 2022, 11:52 AM
Simba
Simba - avatar
+ 1
Share them with us. It will be helpful to understand your problem clearly
22nd Mar 2022, 12:12 PM
Simba
Simba - avatar
0
Simba Oh sorry This is my attempt String n1,n2; Console.Write("enter name1:"); n1=Console.ReadLine(); Console.Write("Inpuet name 2:") n2=Console.ReadLine(); for(int i=0;i<7;i++) { Console.Write("Plyaer 1:"); int player1=Convert.ToInt32(Console.ReadLine()); Console.Write("Plyaer 2:"); int player2=Convert.ToInt32(Console.ReadLine()); Random random=new Random(); int a=random.Next(1,6); Console.WriteLine(a); if(player1==random.Next(1)) { Console.WriteLine("Plyaer 1 is wineer:"); } else { Console.WriteLine("Faild"); } if(player2==random.Next(2)) { Console.WriteLine("Plyaer 2 is wineer:"); } else { Console.WriteLine("Faild"); } }
22nd Mar 2022, 11:46 AM
Arazdeary
Arazdeary - avatar
0
Simba I'm not going to get it, it's not my problem that I want it. Doesn't give the same output
22nd Mar 2022, 11:54 AM
Arazdeary
Arazdeary - avatar
0
Yas
22nd Mar 2022, 12:04 PM
Arazdeary
Arazdeary - avatar