Answer to Question #12098 in C# for Nicole

Question #12098
A program to input a date ( numeric day only entered separately) and output the corresponding astrological sign based on the table below:

DEC 22 - JAN 20 Capricorn
JAN 21 - FEB 19 Aquarius
FEB 20 - MAR 20 Pisces
MAR 21 - APR 20 Aries
APR 21 - MAY 21 Taurus
MAY 22 - JUN 21 Gemini
JUN 22 - JUL 23 Cancer
JUL 24 - AUG 23 Leo
AUG 24 - SEP 23 Virgo
SEP 24 - OCT 23 Libra
OCT 24 - NOV 23 Scorpio
NOV 24 - DEC 21 Sagittarius
1
Expert's answer
2012-07-20T11:22:37-0400
{
class Program
{
static void Main(string[]
args)
{
Console.WriteLine("Input date DD
MMM:");
string inputDate = Console.ReadLine();
int
inputDay = Convert.ToInt32((inputDate.Split(' '))[0]);
string
inputMon = (inputDate.Split(' '))[1];

//Console.WriteLine(inputDate," ",inputMon);
inputMon =
inputMon.ToUpper();
switch (inputMon)

{
case "DEC":

{
if (inputDay > 31) {
Console.WriteLine("Incorrect day"); }

else
if (inputDay < 22)
Console.WriteLine("Sagittarius");
else
Console.WriteLine("Capricorn");
break;

}
case "JAN":

{
if (inputDay > 31) {
Console.WriteLine("Incorrect day"); }

else
if (inputDay < 21)
Console.WriteLine("Capricorn");
else
Console.WriteLine("Aquarius");

break;
}
case
"FEB":
{
if (inputDay > 29)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 20)
Console.WriteLine("Aquaruis");
else
Console.WriteLine("Pisces");

break;
}
case
"MAR":
{
if (inputDay > 31)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 21)
Console.WriteLine("Pisces");
else
Console.WriteLine("Aries");

break;
}
case
"APR":
{
if (inputDay > 30)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 21)
Console.WriteLine("Aries");
else
Console.WriteLine("Taurus");

break;
}
case
"MAY":
{
if (inputDay > 31)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 22)
Console.WriteLine("Taurus");
else
Console.WriteLine("Gemini");

break;
}
case
"JUN":
{
if (inputDay > 30)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 22)
Console.WriteLine("Gemini");
else
Console.WriteLine("Cancer");

break;
}
case
"JUL":
{
if (inputDay > 31)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 24)
Console.WriteLine("Cancer");
else
Console.WriteLine("Leo");

break;
}
case
"AUG":
{
if (inputDay > 31)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 24)
Console.WriteLine("Leo");
else
Console.WriteLine("Virgo");

break;
}
case
"SEP":
{
if (inputDay > 30)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 24)
Console.WriteLine("Virgo");
else
Console.WriteLine("Libra");

break;
}
case
"OCT":
{
if (inputDay > 31)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 24)
Console.WriteLine("Libra");
else
Console.WriteLine("Scorpio");

break;
}
case
"NOV":
{
if (inputDay > 30)
{ Console.WriteLine("Incorrect day"); }

else
if (inputDay < 24)
Console.WriteLine("Scorpio");
else
Console.WriteLine("Sagittarius");

break;
}
default: {
Console.WriteLine("Incorrect month"); break; }
}

Console.ReadKey();
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS