Answer to Question #265072 in C# for mysti

Question #265072

First, ask the user to input how

many members’ information will be entered into the system. Using a linked list, the

program should accept information such as first name, middle name, last name, area code,

telephone number, gender, and age. Upon giving the needed information of each member,

the system will display the information of each member. Use appropriate data types for

each member of the linked list.


give info for member #1

Enter first name: Ta

Enter middle name: Ma

Enter last name: Ta

Enter area code: 047

Enter telephone number: 1-22


Enter gender: male

Enter age: 21

Kindly give the information of member #2

Enter first name: Ja

Enter middle name: La

Enter last name: Ga

Enter area code: 047

Enter telephone number: 2-33


Enter gender: female

Enter age: 18

Welcome to the club Ta Ma Ta!

Your area code and telephone number is (047) 1-22.

You are a male member, and your age is 21.


Welcome to the club Ja La Ga!

Your area code and telephone number are (047) 2-33.

You are a female member, and your age is 18.


1
Expert's answer
2021-11-12T16:30:44-0500
using System;
using System.Collections.Generic;


namespace App
{


    class Member
    {
        private string firstName;
        private string middleName;
        private string lastName;
        private string areaCode;
        private string telephoneNumber;
        private string gender;
        private int age;




        public Member() { }


        public Member(string firstName, string middleName, string lastName, string areaCode,
            string telephoneNumber, string gender, int age)
        {
            this.firstName = firstName;
            this.middleName = middleName;
            this.lastName = lastName;
            this.areaCode = areaCode;
            this.telephoneNumber = telephoneNumber;
            this.gender = gender;
            this.age = age;
        }


        public override string ToString()
        {
            return "Welcome to the club " + this.firstName + " " + this.middleName + " " +
                this.lastName + "!" + Environment.NewLine +
                "Your area code and telephone number is (" +
                this.areaCode + ") " + this.telephoneNumber + "." + Environment.NewLine +
                "You are a " + this.gender + " member, and your age is " + this.age.ToString() + ".";
        }


    }


    class Program
    {




        static void Main(string[] args)
        {


            LinkedList<Member> members = new LinkedList<Member>();




            Console.Write("How many members' information will be entered into the system?: ");
            int N = int.Parse(Console.ReadLine());


            
            for (int i = 1; i <= N; i++)
            {
                if (i < N)
                {
                    Console.WriteLine("give info for member #{0}", i);
                }
                else {
                    Console.WriteLine("Kindly give the information of member #{0}", i);
                }
                




                Console.Write("Enter first name: ");
                string firstName = Console.ReadLine();
                Console.Write("Enter middle name: ");
                string middleName = Console.ReadLine();
                Console.Write("Enter last name: ");
                string lastName = Console.ReadLine();
                Console.Write("Enter area code: ");
                string areaCode = Console.ReadLine();
                Console.Write("Enter telephone number: ");
                string telephoneNumber = Console.ReadLine();
                Console.Write("\nEnter gender: ");
                string gender = Console.ReadLine();
                Console.Write("Enter age: ");
                int age = int.Parse(Console.ReadLine());
                members.AddLast(new Member( firstName, middleName,  lastName,  areaCode, telephoneNumber,  gender,  age));
            }
            Console.WriteLine();
            foreach(Member member in members) 
            {
                Console.WriteLine(member.ToString()+Environment.NewLine);
            }




            Console.ReadLine();
        }




    }
}

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