Question
Introduction to Object-Oriented Programming: Ch.6 Case Problem 1 I am having difficulty completing the following programming assignment. The Parameters of the assignment are as follows:
Introduction to Object-Oriented Programming: Ch.6 Case Problem 1
I am having difficulty completing the following programming assignment. The Parameters of the assignment are as follows:
Instructions:
- Now, modify the version of the GreenvilleRevenue program created in Chapter 5 so that after the user enters the number of contestants in this years competition.
- The user is prompted for the appropriate number of contestant names and a code for each contestant that indicates the type of talent:
- S for singing
- D for dancing
- M for playing a musical instrument
- O for other.
- Make sure that all entered codes are valid, and if not, re-prompt the user to enter a correct code.
- For example, if Y is input, output Y is not a valid code, and re-prompt the user until a valid code is entered.
- After contestant data entry is complete, display a count of each type of talent.
- For example, if there were ten singers, four dancers, 7 people who play musical instruments, and 1 in the other category, the output should be:
The types of talent are:
Singing 10
Dancing 4
Musical instrument 7
Other 1
- Then, continuously prompt the user for a talent code until the user enters a sentinel value (the uppercase character Z should be used as the sentinel value).
- With each code entry, display a list of the contestants with that code, or display a message that the code is not valid and re-prompt the user.
- For example, if M is entered, the output might be:
Contestants with talent Musical instrument are:
Michelle
Nick
- If U is entered, the output should be U is not a valid code.
The current issues that I am having:
- I cannot get the output for point 6 to tally the number of talent codes that have been entered for each contestant.
- I cannot get the output for the tally of which contestants have what talent as found in point 9.
- I cannot get the sentinel value Z to actually terminate the problem.
Here are images of the prompt:
using System; using static System.Console; using static System.String; namespace GreenvilleRevenueArray2 { class Program { static void Main() { const int MIN_CONTESTANTS = 0; const int MAX_CONTESTANTS = 30; string entryString; int numThisYear;
char[] talentCodes = { 'S', 'D', 'M', '0' }; string[] talentCodeStrings = { "Singing", "Dancing", "Musical Instrument", "Other" }; string entryCode; char entryCodeValue; const char QUIT = 'Z'; int i = 0; int sing = 0; int dance = 0; int music = 0; int other = 0;
Write("Enter number of contestants this year >> "); entryString = ReadLine(); numThisYear = Convert.ToInt32(entryString);
while (numThisYear MAX_CONTESTANTS) { WriteLine("Number must be between {0} and {1}", MIN_CONTESTANTS, MAX_CONTESTANTS); Write("Enter number of contestants this year >> "); entryString = ReadLine(); numThisYear = Convert.ToInt32(entryString); } string[] contestants = new string[numThisYear]; char[] talents = new char[numThisYear];
for (i = 0; i > "); entryCode = ReadLine(); entryCodeValue = Convert.ToChar(entryCode); if (entryCodeValue == 'S' || entryCodeValue == 'D' || entryCodeValue == 'M' || entryCodeValue == 'O') { entryCodeValue = talents[i]; isValidTalentCode = true; } else { WriteLine("{O} is not a valid code.", entryCodeValue); WriteLine("Please enter a valid code.");
} } } for (i = 0; i
WriteLine("Please enter a talent code 'S','D','M','O' to see the contestants and their talents or enter 'Z' to quit."); entryCode = ReadLine(); entryCodeValue = Convert.ToChar(entryCode);
while (entryCodeValue != QUIT) { if (entryCodeValue != 'S' && entryCodeValue != 'D' && entryCodeValue != 'M' && entryCodeValue != 'O') { WriteLine("{0} is not a valid code.", entryCodeValue); WriteLine("Please enter a valid code."); } for (i = 0; i
else if (entryCodeValue == QUIT) { break; } } } } } }
Case Problem 6-1 OInstructions In previous chapters, you created applications for the Greenville Idol competition. Now, modify the version of the GreenvilleRevenue program created in Chapter 5 so that after the user enters the number of contestants in this year's competition, the user is prompted for the appropriate number of contestant names and a code for each contestant that indicates the type of talent: s/p S for singing D for dancing M for playing a musical instrument .O for other. Make sure that all entered codes are valid, and if not, reprompt the user to enter a correct code. For example, if Y is input, output Y is not a valid code, and reprompt the user until a valid code is entered. After contestant data entry is complete, display a count of each type of talent. For example, if there were ten singers, four dancers, 7 people who play musical instruments, and 1 in the other category, the output should be: The types of talent are Singing Dancing Musical instrument 7 Other 10 4 Then, continuously prompt the user for a talent code until the user enters a sentinel value (the uppercase character Z should be used as the sentinel value). Then, continuously prompt the user for a talent code until the user enters a sentinel value (the uppercase character Z should be used as the sentinel value With each code entry, display a list of the contestants with that code, or display a message that the code is not valid and reprompt the user. For example, if M is entered, the output might be: Contestants with talent Musical instrunent are: Michelle Nick If U is entered, the output should be U is not a valid code. AMCIWINDOWS system321cmd.exe Enter number of contestants last year > 2 Enter number of contestants this year 2 Please enter a contestant's name: Joe Please enter contestant's skill: S for singing, D for dancing, M for musical instrument, 0 for other S Please enter a contestant's name: John Please enter contestant's skill: S for singing, D for dancing, M for musical instrument, 0 for other >>S The Types of Talent are: Singing ancing usical instrument 0 Other Please enter a talent code 'S', 'D', 'M','0' to see the contestants and their talents or enter 'Z' to quitStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started