Karanbir S.

asked • 06/02/21

Why is my visual studio c# code not working on .net fiddle c# compiler?

Here is my code. It should ask the user and let it input.

The compiler is called dotnetfiddle.net

I can't submit from any other compiler.

Please fix the problem in code if needed.

using System;


class Date

{


static void Zellercongruence(int day, int month, int year)

{

if (month == 1)

{

month = 13;

year--;

}

if (month == 2)

{

month = 14;

year--;

}

int q = day;

int m = month;

int k = year % 100;

int j = year / 100;

int h = q + 13 * (m + 1) / 5 + k + k / 4

+ j / 4 + 5 * j;

h = h % 7;

switch (h)

{

case 1:

Console.WriteLine(day + "/" + month + "/" + year + " was a Saturday");

Console.WriteLine("Saturday's child is full of love.");

break;


case 2:

Console.WriteLine(day + "/" + month + "/" + year + " was a Sunday");

Console.WriteLine("Sunday's child is full of joy.");

break;


case 3:

Console.WriteLine(day + "/" + month + "/" + year + " was a Monday");

Console.WriteLine("Monday's child is full of vigor.");

break;


case 4:

Console.WriteLine(day + "/" + month + "/" + year + " was a Tuesday");

Console.WriteLine("Tuesday's child is full of grace.");

break;


case 5:

Console.WriteLine(day + "/" + month + "/" + year + " was a Wednesday");

Console.WriteLine("Wednesday's child is full of cuteness.");

break;


case 6:

Console.WriteLine(day + "/" + month + "/" + year + " was a Thursday");

Console.WriteLine("Thursday's child is full of passion.");

break;


case 0:

Console.WriteLine(day + "/" + month + "/" + year + " was a Friday");

Console.WriteLine("Friday's child is full of brightness.");

break;

}

}


public static void Main()

{

string restart = "This variable will let my quit the program.";

while (restart != "q")

{

Console.WriteLine("Please enter the date of birth in format: mm,dd,yr");

var line = Console.ReadLine();

var data = line.Split(',');

var dd = int.Parse(data[0].Replace(" ", string.Empty));

var mm = int.Parse(data[1].Replace(" ", string.Empty));

var yy = int.Parse(data[2].Replace(" ", string.Empty));


Zellercongruence(dd, mm, yy);

Console.WriteLine("Please enter q to quit and any other key to continue.");

restart = Console.ReadLine();

Console.Clear();

}

}

}

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.