Write a twoclass C application that creates a customer code

Write a two-class C# application that creates a customer code to be placed on a mailing label for a magazine. Allow the user to input their full name with the first name entered first. Prompt them to separate their first and last name with a space. Ask for their birthdate in the format of mm/dd/yyyy. Ask for the month (number) they purchased a subscription and ask for their zip code. Your mailing label should contain the last name, followed by their year of birth, the number of characters in the full name, the first three characters of the month they purchased the subscription, and the last two digits of their zip. The code for Bob Clocksom born 01/22/1993, who purchased his subscription during the 10th month of the year and lists 32226 as his zip code would be Clocksom9312Oct26.

Solution

CustomerCodeApp.cs


using System;

namespace CustomerCodeApp
{
    class CustomerCodeAppProgram
    {
        static void Main()
        {
            string fullName;
            string birthdate;
            int monthNumber;
            int zipCode;
            string inValue;
            char anotherCode = \'N\';

            DisplayInstructions();


            do
            {
                GetCustomerInfo(out fullName, out birthdate, out monthNumber, out zipCode);
              
                CustomerCodeAppClass code = new CustomerCodeAppClass(fullName, birthdate, monthNumber);

                Console.WriteLine(\"The Customer Code is: {0}{1}{2}{3}\", code.LastName, code.BirthYear % 100, code.PurchMonth, zipCode % 100);

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine(\"Would you like to determine another Customer Code? (y or n)\");
                inValue = Console.ReadLine();
                anotherCode = Convert.ToChar(inValue);
                Console.Clear();
            }
            while ((anotherCode == \'Y\') || (anotherCode == \'y\'));

        }
        // This method will display the instructions
        static void DisplayInstructions()
        {
            Console.WriteLine(\"Welcome to the Customer Code App!!\");
            Console.WriteLine(\"**********************************\");
            Console.WriteLine();
            Console.WriteLine(\"This app will determine the Customer Code for the mailing label\");
            Console.WriteLine(\"that will appear on the Magazine.\");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine(\"Press any key to enter Customer Info...\");
            Console.ReadKey();
            Console.Clear();
        }
        // This method will allow the user to enter the Customer Information
        public static void GetCustomerInfo(out string fullName, out string birthdate, out int monthNumber, out int zipCode)
        {
            Console.WriteLine(\"Please Enter-\");
            Console.Write(\"Customer Name (First Last): \");
            fullName = Console.ReadLine();
            Console.Write(\"Customer Birthdate (mm/dd/yyyy): \");
            birthdate = Console.ReadLine();
            Console.Write(\"Date of Month subscription purchased (Number of Month): \");
            monthNumber = int.Parse(Console.ReadLine());
            Console.Write(\"Customer Zip Code (12345): \");
            zipCode = int.Parse(Console.ReadLine());
            Console.Clear();
        }
    }
}
CustomerCodeAppClass.cs


using System;

namespace CustomerCodeApp
{
    class CustomerCodeAppClass
    {
        // Data fields
        private string custFullName;
        private string custBirthdate;
        private int custMonthNumber;
        private string lastName;
        private int birthYear;
        private string purchMonth;

        // Properties
        public string CustFullNames
        {
            get
            {
                return custFullName;
            }
            set
            {
                custFullName = value;
            }
        }
        public string CustBirthdate
        {
            get
            {
                return custBirthdate;
            }
            set
            {
                custBirthdate = value;
            }
        }
        public int CustMonthNumber
        {
            get
            {
                return custMonthNumber;
            }
            set
            {
                custMonthNumber = value;
            }
        }
        // Read only properites
        public string LastName
        {
            get
            {
                ParseName(custFullName);
                return lastName;
            }
        }
        public int BirthYear
        {
            get
            {
                ParseBirthdate(custBirthdate);
                return birthYear;
            }
        }
        public string PurchMonth
        {
            get
            {
                ReturnMonth(custMonthNumber);
                return purchMonth;
            }
        }
      
        // Default Constructor
        public CustomerCodeAppClass()
        {
        }
      
        // Parameterized Constructor
        public CustomerCodeAppClass(string fn, string bd, int mn)
        {
            custFullName = fn;
            CustBirthdate = bd;
            custMonthNumber = mn;
        }
      
        // This method will parse last name from full name
        public void ParseName(string fn)
        {
            string[] nameParts = fn.Split(\' \');

            lastName = nameParts[1];
        }
      
        // This method will parse year of birth from birthdate
        public void ParseBirthdate(string bd)
        {
            string[] dateParts = bd.Split(\'/\');
          
            birthYear = Convert.ToInt32(dateParts[2]);
        }
      
        // This method will determine month name from month number
        public void ReturnMonth(int mn)
        {
            string[] monthNames = { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" };

            monthNames[0] = monthNames[0].TrimStart(\'0\');

            purchMonth = monthNames[mn - 1];
        }
    }
}

Write a two-class C# application that creates a customer code to be placed on a mailing label for a magazine. Allow the user to input their full name with the f
Write a two-class C# application that creates a customer code to be placed on a mailing label for a magazine. Allow the user to input their full name with the f
Write a two-class C# application that creates a customer code to be placed on a mailing label for a magazine. Allow the user to input their full name with the f
Write a two-class C# application that creates a customer code to be placed on a mailing label for a magazine. Allow the user to input their full name with the f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site