A guy in my class made a program to determine the difference between 2 numbers. The way he did it was really ineffective and I told him that. He didn't believe me and wanted me to write better code. I wrote all of the code I need in Visual Studio but every time I try to run the code I get the error message
CS5001: does not contain a static 'main' method suitable for an entry point
I have been looking in the internet for solutions for quite a long time now and I tried a lot out but none of it has worked. I code in C#. I will be really thankful if anyone here can help me. this is my code:
namespace Determine_difference
{
public class Program
{
public static void Main()
{
}
int a, b, c, d;
public void Start()
{
a = 0;
b = 1; //this is the difference between the numbers
c = 1; //c is used to determine how big or small the searched number is. This is kind of unnecessary but I was tired when i wrote this
d = 1; //d is used so that the console doesn't get spammed with the answers
}
public void Update()
{
if (a < b) //this next part only gets executed when the searched number is larger than 0
{
if(b-c > a) //the next part then only gets triggered if the searched number minus c are larger than 0
{
c += 1; //c gets 1 higher
}
else if(b-c==a) //if the searched number minus c are equal to 0 this part gets executed
{
if (d == 1) // then this part gets executed if d is equal to 1, this is so that the console only prints once
{
Console.Write("+"); //the console writes "+"
Console.Write(c); //and the searched number
d = 0; //d is now equal to 0 so that this part of the code doesn't get triggered again
}
}
}
if (a > b)
{
if (b - c < a)
{
c += 1;
}
else if (b + c == a)
{
if (d == 1)
{
Console.Write("+-c");
Console.Write(c);
d = 0;
}
}
}
if (a == b)
{
if (d == 0)
{
Console.WriteLine("+/ -0");
d = 0;
}
}
}
}
}