Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Is there something wrong with this code? Every time I run chucks on it, it comes back saying that there is an unexpected output Jill.

Is there something wrong with this code?

Every time I run chucks on it, it comes back saying that there is an unexpected output "Jill".

using System;

using static System.Console;

using System.Globalization;

// Define the Contestant class

class Contestant

{

// Declare public static arrays to hold talent codes and descriptions

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

public static string[] talentStrings = { "Singing", "Dancing", "Musical instrument", "Other" };

// Declare a property Name to hold a contestant's name

public string Name { get; set; }

// Declare fields for talent code and description

private char talentCode;

public char TalentCode

{

set

{

// Assign a code only if it is valid

if (Array.IndexOf(talentCodes, value) != -1)

{

talentCode = value;

}

else

{

// Otherwise, assign I for Invalid

talentCode = 'I';

}

}

get

{

return talentCode;

}

}

// Declare a read-only property Talent that holds the talent description

public string Talent

{

get

{

// Assign a value to the talent description when the code is set

return talentStrings[Array.IndexOf(talentCodes, talentCode)];

}

}

}

class GreenvilleRevenue

{

static void Main()

{

// Prompt the user for the number of contestants in this year's competition

int numContestants;

do

{

Write("Enter the number of contestants in this year's competition (0 to 30): ");

} while (!int.TryParse(ReadLine(), out numContestants) || numContestants < 0 || numContestants > 30);

// Calculate the expected revenue

double revenue = 25 * numContestants;

// Display the expected revenue

WriteLine("Revenue expected this year is {0}", revenue.ToString("C", CultureInfo.GetCultureInfo("en-US")));

// Declare an array to hold contestants

Contestant[] contestants = new Contestant[numContestants];

// Prompt the user for names and talent codes for each contestant entered

for (int i = 0; i < numContestants; i++)

{

// Prompt the user for a name

Write("Enter the name of contestant {0}: ", i + 1);

contestants[i] = new Contestant { Name = ReadLine() };

// Display a list of the valid categories

WriteLine("The types of talent are:");

WriteLine("S\tSinging");

WriteLine("D\tDancing");

WriteLine("M\tMusical instrument");

WriteLine("O\tOther");

// Prompt the user for a talent code

char code;

do

{

Write("Talent codes are Joey {0}: ", contestants[i].Name);

} while (!char.TryParse(ReadLine(), out code));

contestants[i].TalentCode = code;

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

What is IUPAC system? Name organic compounds using IUPAC system.

Answered: 1 week ago

Question

What happens when carbonate and hydrogen react with carbonate?

Answered: 1 week ago

Question

1. The evaluation results can be used to change the program.

Answered: 1 week ago

Question

5. To determine the financial benefits and costs of the program.

Answered: 1 week ago