Ant6729Gr
New member
- Joined
- Jun 29, 2019
- Messages
- 1
- Programming Experience
- Beginner
Hello
I need to cycle my attempts untill I dont want to insert data
Here my code
Could you help me?
I need to cycle my attempts untill I dont want to insert data
Here my code
Could you help me?
Test:
using System;
namespace blabla
{
public delegate int BinaryOp(int x, int y);
public class SimpleMath
{
public static int Add(int x, int y)
{ return x + y; }
}
class Program
{
static void Main(string[] args)
{
BinaryOp b = new BinaryOp(SimpleMath.Add);
string useranswer;
int userresult;
int pcresult;
Console.WriteLine("Insert first number");
int x = (Convert.ToInt16(Console.ReadLine()));
Console.WriteLine("Insert second number");
int y = (Convert.ToInt16(Console.ReadLine()));
//MyMethod();
Console.WriteLine("Insert sum of x and y");
userresult = (Convert.ToInt16(Console.ReadLine()));
pcresult = b(x, y);
if (userresult != pcresult)
{
Console.WriteLine("Something wrong with your calculations, man..." + "\n" + "Would you like to continue...? (y/n) : ");
useranswer = Convert.ToString(Console.ReadLine());
switch(useranswer)
{
case "y":
//Console.WriteLine("Insert sum of x and y");
//userresult = (Convert.ToInt16(Console.ReadLine()));
break;
case "n":
Console.WriteLine("If I were you, I’d better practice over....You never know...");
break;
default:
break;
}
}
else
{
Console.WriteLine("Right");
}
}
}
}