Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C#: In Chapter 6, you continued to modify the GreenvilleRevenue program. N

ID: 3672858 • Letter: U

Question

Using C#: In Chapter 6, you continued to modify the GreenvilleRevenue program. Now, modify the program so that the major functions appear in the following individual methods:

- A method that gets and returns a valid number of contestants and is called twice- once for last year's number of contestants and one for this year's value

-A method that accepts the number of contestants this year and last year, and displays one of the three messages that describes the relationship between the two contestant values

-A method that fills the array of competitors and their talent codes

A method that continuously prompts for talent codes and displays contestants with the corresponding talent until a sentinel value is entered

Please use the code below for modification:

namespace GreenvilleRevenue
{
    class Program
        {
        static void Main(string[] args)
            {
            int entFee = 25;
            int contLast;
            int contCurr;
            int contMin = 0;
            int contMax = 30;
            int other = 0;
            int dance = 0;
            int instrument = 0;
            int sing = 0;
            string entry;

            Console.WriteLine("No. of contestant's in last year's competition? Enter a number from 0 to 30.");
                string input = Console.ReadLine();
                contLast = Convert.ToInt32(input);

                while (contLast < contMin || contLast > contMax)
                {
                    Console.WriteLine(" You have entered and invalid response, please enter a valid number.");
                    contLast = Convert.ToInt32(Console.ReadLine());
                }

                Console.WriteLine(" No. of contestants in this year's competition? Enter a number from 0 to 30.");
                input = Console.ReadLine();
                contCurr = Convert.ToInt32(input);

                while (contCurr < contMin || contCurr > contMax)
                {
                    Console.WriteLine(" You have entered and invalid response, please enter a valid number.");
                    input = Console.ReadLine();
                    contCurr = Convert.ToInt32(input);
                }

            string[] contestant = new String[contCurr];
            string[] skill = new String[contCurr];

            for (int x = 0; x < contCurr; ++x)
            {
                Console.WriteLine(" Please enter contestant no. " + (x + 1) + "'s name");
                contestant[x] = Console.ReadLine();
                bool correct = false;
                while (!correct)
                {
                    Console.WriteLine(" Please enter contestant " + (x + 1) + " 's skill, 'S' for sing 'D' for dance 'M' for " +
                        "musical instrument 'O' for other");
                    string type = Console.ReadLine().ToUpper();

                    if (type == "S" || type == "D" || type == "M" || type == "O")
                    {
                        skill[x] = type;
                        correct = true;
                    }
                    else
                    {
                        Console.WriteLine("Please enter a valid parameter.");
                    }
                }
            }
            for (int x = 0; x < skill.Length; ++x)
            {
                if (skill[x] == "O")
                {
                    ++other;
                }
                else if (skill[x] == "S")
                {
                    ++sing;
                }
                else if (skill[x] == "D")
                {
                    ++dance;
                }
                else if (skill[x] == "M")
                {
                    ++instrument;
                }
            }
            Console.Clear();
            Console.WriteLine("There are:");
            Console.WriteLine("{0} dancers", dance);
            Console.WriteLine("{0} singers", sing);
            Console.WriteLine("{0} musicians", instrument);
            Console.WriteLine("{0} people with other skills", other);
            Console.WriteLine(" Please enter a skill code, 'S' 'D' 'M' 'O', to see a list of contestants with that skill or enter '!' to exit.");
            entry = Console.ReadLine().ToUpper();
            while (entry != "!")
            {
                if (entry != "S" && entry != "D" && entry != "M" && entry != "O")
                {
                    Console.WriteLine(" Please try again: Enter a VALID skill code, 'S' 'D' 'M' 'O', to see a list of contestants with that skill or '!' to exit.");
                    entry = Console.ReadLine().ToUpper();
                    if (entry == "!")
                        break;
                }
                for (int x = 0; x < skill.Length; ++x)
                {
                    if (entry == skill[x])
                        Console.WriteLine(" Contestant " + contestant[x] + " skill " + skill[x]);
                }
                Console.WriteLine(" Please enter a skill code, 'S' 'D' 'M' 'O', to see a list of contestants with that skill or enter '!' to exit");
                entry = Console.ReadLine().ToUpper();
            }

            Console.Clear();
            if (contCurr > contLast * 2)
                {
                    Console.WriteLine("The competition is more than twice as big this year! ");
                    Console.WriteLine(" The revenue expected for this year's competition is {0:C}", (contCurr * entFee));
                }
                else

                if (contCurr > contLast && contCurr <= (contLast * 2))
                {
                    Console.WriteLine("The competition is bigger than ever! ");
                    Console.WriteLine(" The revenue expected for this year's competition is {0:C}", (contCurr * entFee));
                }
                else

                if (contCurr < contLast)
                {
                    Console.WriteLine("A tighter race this year! Come out and cast your vote! ");
                    Console.WriteLine(" The revenue expected for this year's competition is {0:C}", (contCurr * entFee));
                }
            }
        }
    }

Explanation / Answer

using System.IO;
using System;


class Program
        {
        static void Main(string[] args)
            {
            int entFee = 25;
            int contLast;
            int contCurr;
            int contMin = 0;
            int contMax = 30;
            int other = 0;
            int dance = 0;
            int instrument = 0;
            int sing = 0;
         

            string message = ("No. of contestant's in last year's competition? Enter a number from 0 to 30.");
               contLast = getNoOfContestants(message, contMin, contMax);

                message = (" No. of contestants in this year's competition? Enter a number from 0 to 30.");
            
                contCurr = getNoOfContestants(message, contMin, contMax);

            string[] contestant = new String[contCurr];
            string[] skill = new String[contCurr];
            getContestantsInfo(contestant, skill);
            for (int x = 0; x < skill.Length; ++x)
            {
                if (skill[x] == "O")
                {
                    ++other;
                }
                else if (skill[x] == "S")
                {
                    ++sing;
                }
                else if (skill[x] == "D")
                {
                    ++dance;
                }
                else if (skill[x] == "M")
                {
                    ++instrument;
                }
            }
            Console.Clear();
            Console.WriteLine("There are:");
            Console.WriteLine("{0} dancers", dance);
            Console.WriteLine("{0} singers", sing);
            Console.WriteLine("{0} musicians", instrument);
            Console.WriteLine("{0} people with other skills", other);
            displayContsByTalent(contestant,skill);


            Console.Clear();
            displayCompInfo(contCurr, contLast,entFee);
        }

//- A method that gets and returns a valid number of contestants and is called twice- once for last year's number of contestants and one for this year's value
static int getNoOfContestants(string message, int contMin, int contMax) {
                Console.WriteLine("No. of contestant's in last year's competition? Enter a number from 0 to 30.");
                string input = Console.ReadLine();
                int conts = Convert.ToInt32(input);

                while (conts < contMin || conts > contMax)
                {
                    Console.WriteLine(" You have entered and invalid response, please enter a valid number.");
                    conts = Convert.ToInt32(Console.ReadLine());
                }
        return conts;

}

static string getSkill(int contNum) {
                bool correct = false;
                string type = "";
                while (!correct)
                {
                    Console.WriteLine(" Please enter contestant " + contNum + " 's skill, 'S' for sing 'D' for dance 'M' for " +
                        "musical instrument 'O' for other");
                    type = Console.ReadLine().ToUpper();

                    if (type == "S" || type == "D" || type == "M" || type == "O")
                    {
                        correct = true;
                    }
                    else
                    {
                        Console.WriteLine("Please enter a valid parameter.");
                    }
                }
return type;

}

//A method that continuously prompts for talent codes and displays contestants with the corresponding talent until a sentinel value is entered
static void displayContsByTalent(string[] contestant, string[] skill) {

         Console.WriteLine(" Please enter a skill code, 'S' 'D' 'M' 'O', to see a list of contestants with that skill or enter '!' to exit.");
            string entry = Console.ReadLine().ToUpper();
            while (entry != "!")
            {
                if (entry != "S" && entry != "D" && entry != "M" && entry != "O")
                {
                    Console.WriteLine(" Please try again: Enter a VALID skill code, 'S' 'D' 'M' 'O', to see a list of contestants with that skill or '!' to exit.");
                    entry = Console.ReadLine().ToUpper();
                    if (entry == "!")
                        break;
                }
                for (int x = 0; x < skill.Length; ++x)
                {
                    if (entry == skill[x])
                        Console.WriteLine(" Contestant " + contestant[x] + " skill " + skill[x]);
                }
                Console.WriteLine(" Please enter a skill code, 'S' 'D' 'M' 'O', to see a list of contestants with that skill or enter '!' to exit");
                entry = Console.ReadLine().ToUpper();
            }


}

//A method that fills the array of competitors and their talent codes
static void getContestantsInfo(string[] contestant, string[] skill) {
for (int x = 0; x < contestant.Length; ++x)
            {
                Console.WriteLine(" Please enter contestant no. " + (x + 1) + "'s name");
                contestant[x] = Console.ReadLine();
                skill[x] = getSkill(x+1);
            }

}
   


//-A method that accepts the number of contestants this year and last year, and displays one of the three messages that describes the relationship between the two contestant values

static void displayCompInfo(int contCurr, int contLast, int entFee) {

           if (contCurr > contLast * 2)
                {
                    Console.WriteLine("The competition is more than twice as big this year! ");
                    Console.WriteLine(" The revenue expected for this year's competition is {0:C}", (contCurr * entFee));
                }
                else

                if (contCurr > contLast && contCurr <= (contLast * 2))
                {
                    Console.WriteLine("The competition is bigger than ever! ");
                    Console.WriteLine(" The revenue expected for this year's competition is {0:C}", (contCurr * entFee));
                }
                else

                if (contCurr < contLast)
                {
                    Console.WriteLine("A tighter race this year! Come out and cast your vote! ");
                    Console.WriteLine(" The revenue expected for this year's competition is {0:C}", (contCurr * entFee));
                }
          

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote