please make it run using static System.Console; class GreenvilleRevenue {   static void Main()     {       const int MIN_CONTESTANTS = 0;       const int MAX_CONTESTANTS = 30;       int num;       int revenue = 0;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please make it run

using static System.Console;

class GreenvilleRevenue

{

  static void Main()

    {

      const int MIN_CONTESTANTS = 0;

      const int MAX_CONTESTANTS = 30;

      int num;

      int revenue = 0;

      Contestant[] contestants = new Contestant[MAX_CONTESTANTS];

      num = getContestantNumber(MIN_CONTESTANTS, MAX_CONTESTANTS);

      revenue = getContestantData(num, contestants, revenue);

      WriteLine("\n\nRevenue expected this year is {0}", revenue.ToString("C"));

      getLists(num, contestants);

  }

  private static int getContestantNumber(int min, int max)

  {

    string entryString;

    intnum =max+1;

    Write("Enter number of contestants >> ");

    entryString = ReadLine();

    while(num < min || num > max)

   

    {

      if(!int.TryParse(entryString, out num))

     

        {

 

          WriteLine("Format invalid");

          num=max+1;

          Write("Enter number of contestants >> ");

          entryString = ReadLine(); }

          else

          {

            if(num < min || num > max)

            {

              WriteLine("Number must be between {0} and {1}", min, max);

              num=max+1;

              Write("Enter number of contestants >> ");

              entryString = ReadLine();

              }

              }

              }

         

          return num;

         

          }

          private static int getContestantData(int num, Contestant[] contestants, int revenue)

          {

            const int ADULTAGE = 17;

            const int TEENAGE = 12;

            intx=0;

            string name;

            char talent;

            int age;

            while(x < num)

            {

            Write("Enter contestant name >> ");

            name = ReadLine();

            WriteLine("Talent codes are:");

            for(int y = 0; y < Contestant.talentCodes.Length; ++y)

            WriteLine(" {0} {1}", Contestant.talentCodes[y]);

            Write(" Enter talent code >> ");

            char.TryParse(ReadLine(), out talent);

            Write(" Enter contestant's age >> ");

            int.TryParse(ReadLine(), out age);

            if(age > ADULTAGE)

              contestants[x] = new AdultContestant();

              else

                if(age > TEENAGE)

                  contestants[x] = new TeenContestant();

              else

              contestants[x] = new ChildContestant();

              contestants[x].Name = name;

              contestants[x].TalentCode = talent;

              revenue += contestants[x].Fee;

              ++x;

 

            }

return revenue;

}

 

private static void getLists(int num, Contestant[] contestants)

{

int x;

char QUIT = 'Z';

char option;

bool isValid;

int pos = 0;

bool found;

WriteLine("\nThe types of talent are:");

for(x = 0; x < Contestant.talentStrings.Length; ++x)

WriteLine("{0, -6}{1, -20}", Contestant.talentCodes[x], Contestant.talentStrings[x]);

Write("\nEnter a talent type or {0} to quit >> ", QUIT);

isValid = false;

while(!isValid)

{

if(!char.TryParse(ReadLine(), out option)) {

isValid = false;

WriteLine("Invalid format - entry must be a single character"); Write("\nEnter a talent type or {0} to quit >> ", QUIT);

} else {

if(option == QUIT) isValid = true;

else {

for(int z = 0; z < Contestant.talentCodes.Length; ++z) {

if(option == Contestant.talentCodes[z]) {

isValid = true;

pos=z; }

} if(!isValid) {

WriteLine("{0} is not a valid code", option); Write("\nEnter a talent type or {0} to quit >> ", QUIT);

} else {

WriteLine("\nContestants with talent {0} are:", Contestant.talentStrings[pos]); found = false;

for(x=0;x<num;++x)

{

if(contestants[x].TalentCode == option) {

WriteLine(contestants[x].ToString());

found = true; }

} if(!found)

WriteLine("No contestants had talent {0}", Contestant.talentStrings[pos]); isValid = false;

Write("\nEnter a talent type or {0} to quit >> ", QUIT);

} }

} }

} }

class Contestant {

public static char[] talentCodes = {'S', 'D', 'M', 'O'};

public static string[] talentStrings = {"Singing", "Dancing",

"Musical instrument", "Other"}; public string Name {get; set;}

private char talentCode; private string talent; public char TalentCode {

get {

return talentCode; }

set {

int pos = talentCodes.Length;

for(int x = 0; x < talentCodes.Length; ++x)

if(value == talentCodes[x]) pos=x;

if(pos == talentCodes.Length) {

talentCode = 'I';

talent = "Invalid"; }

else {

talentCode = value;

talent = talentStrings[pos]; }

}

}

public string Talent {

get {

return talent; }

}

public int Fee {get; set;} }

class AdultContestant : Contestant {

public int ADULT_FEE = 30; public AdultContestant()

{

Fee = ADULT_FEE;

}

public override string ToString()

{

return("Adult Contestant " + Name + " " + TalentCode + Fee.ToStrin("C"));

}

}

class TeenContestant : Contestant

{

public int TEEN_FEE = 20;

public TeenContestant()

{

Fee = TEEN_FEE; }

public override string ToString()

{

return("Teen Contestant " + Name + " " + TalentCode + " Fee " + Fee.ToString("C"));

} }

class ChildContestant : Contestant {

public int CHILD_FEE = 15;

public ChildContestant()

{

Fee = CHILD_FEE;

}

public override string ToString()

{

return ("Child Contestant " + Name + " " + TalentCode + "Fee" + Fee.ToString("C"));

}

}

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY