Karanbir S.

asked • 05/20/21

I Don't know where to add this array. I keep getting errors. Please help me.

I want to add this:

String [] strs = { "Fortune for Sunday",

"Fortune for Monday",

"Fortune for Tuesday",

"Fortune for Wednesday",

"Fortune for Thursday",

"Fortune for Friday",

"Fortune for Saturday"

};



Then output the fortune for that day:

Console.WriteLine(strs[pp.DayOfWeek]);


Please help me add to my program:

using System;


class dttimeex57

{

static void Main()

{

int yr, mn, dt;


Console.Write("\n\n Find the day for a given date :\n");

Console.Write("------------------------------------\n");


Console.Write(" Input the Day : ");

dt = Convert.ToInt32(Console.ReadLine());

Console.Write(" Input the Month : ");

mn = Convert.ToInt32(Console.ReadLine());

Console.Write(" Input the Year : ");

yr = Convert.ToInt32(Console.ReadLine());

DateTime d = new DateTime(yr, mn, dt);

Console.WriteLine(" The formatted Date is : {0}", d.ToString("dd/MM/yyyy"));

DateTime pp;

pp = DayOfWeek(d);


Console.WriteLine(" The day for the date is : {0}\n ", pp.DayOfWeek);

}

public static DateTime DayOfWeek(DateTime dt)

{

DateTime ss = new DateTime(dt.Year, dt.Month, dt.Day);

return ss;

}

}


1 Expert Answer

By:

Jared G. answered • 05/20/21

Tutor
4.9 (9)

Experienced in Computer Science

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.