C with loop array and methodSolutionBelow the full code for

C# with loop, array and method:

Solution

Below the full code for the C# console program. The code is tested for the inputs as provided in the screen shots.

**************************************************************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Program
{
    public class BabesName
    {
        public static void Main(string[] args)
        {
           
            string gender,convertedGen;
            string babyname;
            int flag=0;
            int index;
           
            string []girls = {\"Emma\",\"Olivia\",\"Sophia\",\"Ava\",\"Isabella\",\"Mia\",\"Charlotte\",\"Amelia\",\"Emily\",\"Madison\"};
            string []boys= {\"Liam\",\"Noah\",\"Ethan\",\"Mason\",\"Logan\",\"Lucas\",\"Jackson\",\"Aiden\",\"Oliver\",\"Jacob\"};
           do
           {   
            Console.Write(\"Enter your baby\'s gender (M/F): \");
            gender=Console.ReadLine();
            convertedGen=gender.ToUpper();
           
             if((convertedGen==\"M\")||(convertedGen==\"F\")||(convertedGen==\"MALE\")||(convertedGen==\"FEMALE\"))
             {
                flag=1;
               
                if((convertedGen==\"M\")||(convertedGen==\"MALE\"))
                {
                  Console.Write(\"\ Enter your planned name for your son: \");
                  babyname=Console.ReadLine();
                  index= Array.IndexOf(boys, babyname);
                  if (index>=0)
                  {
                      Console.WriteLine(\"\ \ {0} is among the most popular boy names in 2015\",babyname);
                     
                  }
                  else
                   {
                      Console.WriteLine(\"\ \ {0} is not among the most popular boy names in 2015\",babyname);
                     
                   }
                   
                }
               
                else
                {
                  Console.Write(\"\ Enter your planned name for your daughter: \");
                  babyname=Console.ReadLine();
                  index= Array.IndexOf(girls, babyname);
                     if (index>=0)
                      {
                      Console.WriteLine(\"\ \ {0} is among the most popular girl names in 2015\",babyname);
                     
                      }
                    else
                     {
                      Console.WriteLine(\"\ \ {0} is not among the most popular girl names in 2015\",babyname);
                      
                     }

                }

             }
            
             else
             {
                 Console.WriteLine(\"\");
             }
           
          }while(flag!=1);
       }
    }
}

C# with loop, array and method:SolutionBelow the full code for the C# console program. The code is tested for the inputs as provided in the screen shots. ******
C# with loop, array and method:SolutionBelow the full code for the C# console program. The code is tested for the inputs as provided in the screen shots. ******

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site