Mission 3

mail@pastecode.io avatar
unknown
csharp
6 days ago
565 B
1
Indexable
Never
public static string DaysTillSaturday(string dayname)
{
    int daynumber;
    switch (dayname)
    {
        case "Sunday": daynumber = 1; break; 
        case "Monday": daynumber = 2; break;
        case "Tuesday": daynumber = 3; break;
        case "Wednesday": daynumber = 4; break;
        case "Thursday": daynumber = 5; break;
        case "Friday": daynumber = 6; break;
        case "Saturday": daynumber = 7; break;
        default: return "Invalid day name";
    }
    return "There are " + (7 - (daynumber % 7)) + " days till Saturday";
}
Leave a Comment