Answered You can hire a professional tutor to get the answer.
Here is the in-depth question asked in Chapter 9 of "Microsoft Visual C#:
Here is the in-depth question asked in Chapter 9 of "Microsoft Visual C#: An Introduction to Object-Oriented Programming" Where it asked me to create Contestant class with the following characteristics (See my coded program answer after the questions program code - I cannot figure out what is wrong with my code):
The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing, Dancing, Musical instrument, and Other. Name these fields talentCodes and talentStrings respectively.
The class contains an auto-implemented property Name that holds a contestant's name.
The class contains fields for a talent code (talentCode) and description (talent). The set accessor for the code assigns a code only if it is valid. Otherwise, it assigns I for Invalid. The talent description is a read-only property that is assigned a value when the code is set.
Modify the GreenvilleRevenue.cs program (See Program Below) so that it uses the Contestant class and performs the following tasks:
The program prompts the user for the number of contestants in this year's competition; the number must be between 0 and 30. The program continues to prompt the user until a valid value is entered.
The expected revenue is calculated and displayed. The revenue is $25 per contestant. For example if there were 3 contestants, the expected revenue would be displayed as:
year $The program prompts the user for names and talent codes for each contestant entered. Along with the prompt for a talent code, display a list of the valid categories. The categories should be displayed in the following format:
talent are:SingingDancingMusical instrumentOtherAfter data entry is complete, the program displays the valid talent categories and then continuously prompts the user for talent codes and displays the names of all contestants in the category. Appropriate messages are displayed if the entered code is not a character or a valid code.
Here's the GreenvilleRevenue.cs program code:
using System;
using static System.Console;
class GreenvilleRevenue
{
static void Main()
{
const int ENTRANCE_FEE = 25;
const int MIN_CONTESTANTS = 0;
const int MAX_CONTESTANTS = 30;
int numThisYear;
int numLastYear;
int revenue;
string[] names = new string[MAX_CONTESTANTS];
char[] talents = new char[MAX_CONTESTANTS];
char[] talentCodes = { 'S', 'D', 'M', 'O' };
string[] talentCodesStrings = { "Singing", "Dancing", "Musical instrument", "Other" };
int[] counts = { 0, 0, 0, 0 };
numLastYear = GetContestantNumber("last", MIN_CONTESTANTS, MAX_CONTESTANTS);
numThisYear = GetContestantNumber("this", MIN_CONTESTANTS, MAX_CONTESTANTS);
revenue = numThisYear * ENTRANCE_FEE;
WriteLine("Last year's competition had {0} contestants, and this year's has {1} contestants",
numLastYear, numThisYear);
WriteLine("Revenue expected this year is {0}", revenue.ToString("C"));
DisplayRelationship(numThisYear, numLastYear);
GetContestantData(numThisYear, names, talents, talentCodes, talentCodesStrings, counts);
GetLists(numThisYear, talentCodes, talentCodesStrings, names, talents, counts);
}
public static int GetContestantNumber(string when, int min, int max)
{
string entryString;
int num = max + 1;
Write("Enter number of contestants {0} year >> ", when);
entryString = ReadLine();
while (num < min || num > max)
{
if (!int.TryParse(entryString, out num))
{
WriteLine("Invalid format");
num = max + 1;
Write("Enter number of contestants {0} year >> ", when);
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 {0} year >> ", when);
entryString = ReadLine();
}
}
}
return num;
}
public static void DisplayRelationship(int numThisYear, int numLastYear)
{
if (numThisYear > 2 * numLastYear)
WriteLine("The competition is more than twice as big this year!");
else
if (numThisYear > numLastYear)
WriteLine("The competition is bigger than ever!");
else
if (numThisYear < numLastYear)
WriteLine("A tighter race this year! Come out and cast your vote!");
}
public static void GetContestantData(int numThisYear, string[] names, char[] talents, char[] talentCodes, string[] talentCodesStrings, int[] counts)
{
int x = 0;
bool isValid;
while (x < numThisYear)
{
Write("Enter contestant name >> ");
names[x] = ReadLine();
WriteLine("Talent codes are:");
for (int y = 0; y < talentCodes.Length; ++y)
WriteLine(" {0} {1}", talentCodes[y], talentCodesStrings[y]);
Write("Enter talent code >> ");
isValid = false;
while (!isValid)
{
if (!char.TryParse(ReadLine(), out talents[x]))
{
WriteLine("Invalid format. Talent code entry must be a single capitalized character or Z to quit");
}
else
for (int z = 0; z < talentCodes.Length; ++z)
{
if (talents[x] == talentCodes[z])
{
isValid = true;
++counts[z];
}
}
if (!isValid)
{
WriteLine("That is not a valid code");
Write("Enter the talent code >> ");
}
}
++x;
}
}
HERE IS WHAT I CREATED...BUT According to MindTap automated grading IT IS WRONG and got a 0%. Please Help. Thank you. Here's my code that needs help and by the way we use "using static System.Console;" so that we do not need to use "Console.Write" "Console.WriteLine" "Console.ReadLine" etc...:
using System;
using static System.Console;
class Contestant
{
public static string[] talentCodes = { "S", "D", "M", "O" };
public static string[] td = { "Singing", "Dancing", "Musical instrument", "Other" };
private string name;
private string talentCode;
private string talentDest;
public string GetName()
{
return name;
}
public void SetName(string cname)
{
name = cname;
}
public string GetTalentCode()
{
return talentCode;
}
public void SetTalentCode(string sc)
{
bool f = false;
int i;
for (i = 0; i < talentCodes.Length; i++)
{
if (talentCodes[i] == sc)
{
f = true;
break;
}
}
if (f)
{
talentCode = sc;
talentDest = td[i];
}
else
talentCode = "I";
}
public string gettalentDest()
{
return talentDest;
}
}
class Program
{
static void Main(string[] args)
{
int thisYearContestants;
int lastYearContestants;
WriteLine("Please enter the number of contestants from last years competition");
lastYearContestants = GetContestants();
WriteLine("nPlease enter the number of contestants from this years competition");
thisYearContestants = GetContestants();
ArrayFunc(thisYearContestants);
CompetitionFunction(thisYearContestants, lastYearContestants);
}
public static int GetContestants()
{
int lt = 0;
string b;
b = (ReadLine());
int.TryParse(b, out lt);
while (lt > 30 || lt < 0)
{
WriteLine("nYou have entered and invalid response, please enter a valid number between 0 and 30.");
b = (ReadLine());
int.TryParse(b, out lt);
}
return lt;
}
public static void ArrayFunc(int thisyear)
{
Contestant[] contest = new Contestant[thisyear];
string name;
for (int x = 0; x < thisyear; ++x)
{
WriteLine("nPlease enter contestant " + (x + 1) + "'s name");
name = ReadLine();
contest[x] = new Contestant();
contest[x].SetName(name);
bool success = false;
while (!success)
{
WriteLine("nPlease enter contestant " + (x + 1) + " 's talent type.nThe tpyes of talent are:nS SingingnD DancingnM Musical instrumentnO Other");
string type = ReadLine().ToUpper();
for (int i = 0; i < Contestant.talentCodes.Length; i++)
{
if (Contestant.talentCodes[i] == type)
{
contest[x].SetTalentCode(type);
success = true;
}
}
if (!success)
{
WriteLine("nPlease enter a valid parameter");
}
}
}
Talent(contest);
}
public static void Talent(Contestant[] contest)
{
int dance = 0;
int inst = 0;
int sing = 0;
int other = 0;
string start;
for (int x = 0; x < contest.Length; ++x)
{
if (contest[x].GetTalentCode() == "O")
{
++other;
}
else if (contest[x].GetTalentCode() == "S")
{
++sing;
}
else if (contest[x].GetTalentCode() == "D")
{
++dance;
}
else if (contest[x].GetTalentCode() == "M")
{
++inst;
}
}
Clear();
WriteLine("There are:");
WriteLine("{0} dancers", dance);
WriteLine("{0} singers", sing);
WriteLine("{0} musicians", inst);
WriteLine("{0} contestant(s) with other talents", other);
WriteLine("nPlease enter a talent code 'S' 'D' 'M' 'O' to see a list of contestants with that talent or enter 'Z' to exit");
start = ReadLine().ToUpper();
while (start != "Z")
{
if (start != "S" && start != "D" && start != "M" && start != "O")
{
WriteLine("nPlease try again: Enter a VALID talent code 'S' 'D' 'M' 'O' to see a list of contestants with that talent or '!' to exit");
start = ReadLine().ToUpper();
if (start == "Z")
break;
}
for (int i = 0; i < contest.Length; ++i)
{
if (start == contest[i].GetTalentCode())
WriteLine(" Contestant " + contest[i].GetName() + " talent " + contest[i].gettalentDest());
}
WriteLine("nPlease enter a talent code 'S' 'D' 'M' 'O' to see a list of contestants with that talent or enter 'Z' to exit");
start = ReadLine().ToUpper();
}
}
public static void CompetitionFunction(int thisYearContestants, int lastYearContestants)
{
if (thisYearContestants > lastYearContestants * 2)
{
WriteLine("nThe competition is more than twice as big this year!n");
WriteLine("nRevenue expected this year is {0:C}", (thisYearContestants * 25));
}
else
if (thisYearContestants > lastYearContestants && thisYearContestants <= (lastYearContestants * 2))
{
WriteLine("nThe competition is bigger than ever!n");
WriteLine("nRevenue expected this year is {0:C}", (thisYearContestants * 25));
}
else
if (thisYearContestants < lastYearContestants)
{
WriteLine("nA tighter race this year! Come out and cast your vote!n");
WriteLine("nRevenue expected this year is {0:C}", (thisYearContestants * 25));
}
}
}
Again a HUGE thank you for your help.