Question: Using the following code please add in a contestant class. contains public static arrays that hold talent codes and descriptions. Recall that the talent categories
Using the following code please add in a 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 autoimplemented property Name that holds a contestants 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 readonly property that is assigned a value when the code is set. Here is the code:
using System;
using static System.Console;
using System.Globalization;
class GreenvilleRevenue
static void Main
const int ENTRANCEFEE ;
const int MINCONTESTANTS ;
const int MAXCONTESTANTS ;
int numThisYear;
int numLastYear;
int revenue;
string names new stringMAXCONTESTANTS;
char talents new charMAXCONTESTANTS;
char talentCodes SDMO;
string talentCodesStrings Singing "Dancing", "Musical instrument", "Other";
int counts ;
numLastYear getContestantNumberlast MINCONTESTANTS, MAXCONTESTANTS;
numThisYear getContestantNumberthis MINCONTESTANTS, MAXCONTESTANTS;
revenue numThisYear ENTRANCEFEE;
WriteLineLast year's competition had contestants, and this year's has contestants",
numLastYear, numThisYear;
WriteLineRevenue expected this year is revenue.ToStringC;
displayRelationshipnumThisYear numLastYear;
getContestantDatanumThisYear names, talents, talentCodes, talentCodesStrings, counts;
getListsnumThisYear talentCodes, talentCodesStrings, names, talents, counts;
public static int getContestantNumberstring when, int min, int max
string entryString;
int num max ;
WriteEnter number of contestants year when;
entryString ReadLine;
whilenum min num max
ifint.TryParseentryString out num
WriteLineFormat invalid";
num max ;
WriteEnter number of contestants year when;
entryString ReadLine;
else
ifnum min num max
WriteLineNumber must be between and min, max;
num max ;
WriteEnter number of contestants year when;
entryString ReadLine;
return num;
public static void displayRelationshipint numThisYear, int numLastYear
ifnumThisYear numLastYear
WriteLineThe competition is more than twice as big this year!";
else
ifnumThisYear numLastYear
WriteLineThe competition is bigger than ever!";
else
ifnumThisYear numLastYear
WriteLineA tighter race this year! Come out and cast your vote!";
public static void getContestantDataint numThisYear, string names, char talents, char talentCodes, string talentCodesStrings, int counts
int x ;
bool isValid;
whilex numThisYear
WriteEnter contestant name ;
namesx ReadLine;
WriteLineTalent codes are:";
forint y ; y talentCodes.Length; y
WriteLine talentCodesy talentCodesStringsy;
Write Enter talent code ;
isValid false;
whileisValid
ifchar.TryParseReadLine out talentsx
WriteLineInvalid format entry must be a single character";
else
forint z ; z talentCodes.Length; z
iftalentsx talentCodesz
isValid true;
countsz;
ifisValid
WriteLineThat is not a valid code";
Write Enter talent code ;
x;
public static void getListsint numThisYear, char talentCodes, string talentCodesStrings, string names, char talents, int counts
int x;
char QUIT Z;
char option;
bool isValid;
int pos ;
bool found;
WriteLine
The types of talent are:";
forx ; x counts.Length; x
WriteLine talentCodesStringsx countsx;
Write
Enter a talent type or to quit QUIT;
isValid false;
whileisValid
ifchar.TryParseReadLine out option
isValid false;
WriteLineInvalid format entry must be a single character";
Write
Enter a talent type or to quit QUIT;
else
ifoption QUIT
isValid true;
else
forint z ; z talentCodes.Length; z
ifoption talentCodesz
isValid true;
pos z;
ifisValid
WriteLine is not a valid code", option;
Write
Enter a talent type or to quit QUIT;
else
WriteLine
Contestants with talent are:", talentCodesStringspos;
found false;
forx ; x numThisYear; x
iftalentsx option
WriteLinenamesx;
found true;
iffound
WriteLineNo contestants had talent talentCodesStringspos;
isValid false;
Write
Enter a talent type or to quit QUIT;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
