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:
5 Answers
+ 1
You're missing a semicolon at the end of line 4.
That's it?
+ 1
Share them with us.
It will be helpful to understand your problem clearly
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");
}
}
0
Simba
I'm not going to get it, it's not my problem that I want it. Doesn't give the same output
0
Yas