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

C# project - Modify your SDCF-Revenue.cs or SDCF-Revenue project so that the maj

ID: 672236 • Letter: C

Question

C# project - Modify your SDCF-Revenue.cs or SDCF-Revenue project so that the major functions (from the prior versions of this CASE Problem) 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 once for this year's number of contestants.

* 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 numbers (those messages were in an earlier part of this on-going project).

* A method that fills an array of competitors (names) and their talent codes (talent codes from an earlier version of this project).

* A method that continuously prompts for talent codes and displays contestants (names from the array above) with the corresponding talent until a sentinel value (Z for example) is entered.

*************************************************************

using System;

namespace SDCF_Revenue_Version2
{
public class Program
{
public static void Main()
{

const string QUIT = "zzz";
const int LIMIT = 30;
const int FEE = 30;
string answer, name;
int constestantTotal, singingTotal = 0, dancingTotal = 0, mTotal = 0, otherTotal = 0;
Console.Write("Please enter the number of contestants last year(0 to 30): ");
int number1 = Convert.ToInt32(Console.ReadLine());

while (number1 < 0 || number1 > LIMIT)
{
Console.Write("Invalid Entry Please re-enter the number of contestants last year(0 to 30): ");
number1 = Convert.ToInt32(Console.ReadLine());
}

Console.Write("Please enter the number of contestants this year(0 to 30): ");
int number2 = Convert.ToInt32(Console.ReadLine());

while (number2 < 0 || number2 > LIMIT)
{
Console.Write("Invalid Entry Please re-enter the number of contestants this year(0 to 30): ");
number2 = Convert.ToInt32(Console.ReadLine());
}

Console.WriteLine(" Last year's number of competitors was: {0} " +
"and this year's number of competitors is: {1}", number1, number2);

int revenue = number2 * FEE;
Console.WriteLine(" The expected revenue for this year is {0}. ", revenue.ToString("C"));

Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();

while (answer != QUIT)
{
if (answer.Equals("s"))
{
Console.WriteLine("Enter the names of singers(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
while (name != QUIT)
{
singingTotal += 1;
Console.WriteLine("Enter the names of singers: ");
name = Console.ReadLine().ToLower();
  
}
Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();
}
else if (answer.Equals("d"))
{
Console.WriteLine("Enter the names of dancer/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
while (name != QUIT)
{
dancingTotal += 1;
Console.WriteLine("Enter the names of dancer/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
  
}
Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();
}
else if (answer.Equals("m"))
{
Console.WriteLine("Enter the names of musical instrument player/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
while (name != QUIT)
{
mTotal += 1;
Console.WriteLine("Enter the names of musical instrument/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();

}
Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();
}
else if (answer.Equals("o"))
{
Console.WriteLine("Enter the names of other player/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
while (name != QUIT)
{
otherTotal += 1;
Console.WriteLine("Enter the names of other player/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
}
Console.WriteLine("Enter the type of talent category(or enter 'zzz' to quit): ");
answer = Console.ReadLine().ToLower();
}
else
{
Console.Write("Invalid input, please enter again: ");
Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();
}
}
constestantTotal = singingTotal + dancingTotal + mTotal + otherTotal;
Console.WriteLine("Summary");
Console.WriteLine("The total number of contestant: {0}", number2);
Console.WriteLine("The total number of players: {0}", constestantTotal);
Console.WriteLine("The total number of singers: {0}", singingTotal);
Console.WriteLine("The total number of dancers: {0}", dancingTotal);
Console.WriteLine("The total number of musical instrument players: {0}", mTotal);
Console.WriteLine("The total number of other players: {0}", otherTotal);

if (constestantTotal != number2)
{
Console.WriteLine("The number of constestant and number of players do not match, please try again.");
}
else
Console.WriteLine("The number of contestant and number of players match.");
int twice = 2 * number1;
if (number2 >= twice)
Console.WriteLine("The competition is more than twice as big this year");
else if (number2 < twice && number2 > number1)
Console.WriteLine("The competition is bigger than ever!");
else if (number2 <= number1)
Console.WriteLine("A tighter race this year! Come out and cast your vote!");
Console.ReadLine();
}
}
}

Explanation / Answer

using System;

namespace SDCF_Revenue_Version2
{
public class Program
{
public static void Main()
{

const string QUIT = "zzz";
const int LIMIT = 40;
const int FEE = 40;
string answer, name;
int constestantTotal, singingTotal = 0, dancingTotal = 0, mTotal = 0, otherTotal = 0;
Console.Write("Please enter the number of contestants last year(0 to 30): ");
int number1 = Convert.ToInt32(Console.ReadLine());

while (number1 < 0 || number1 > LIMIT)
{
Console.Write("Invalid Entry Please re-enter the number of contestants last year(0 to 30): ");
number1 = Convert.ToInt32(Console.ReadLine());
}

Console.Write("Please enter the number of contestants this year(0 to 30): ");
int number2 = Convert.ToInt32(Console.ReadLine());

while (number2 < 0 || number2 > LIMIT)
{
Console.Write("Invalid Entry Please re-enter the number of contestants this year(0 to 30): ");
number2 = Convert.ToInt32(Console.ReadLine());
}

Console.WriteLine(" Last year's number of competitors was: {0} " +
"and this year's number of competitors is: {1}", number1, number2);

int revenue = number2 * FEE;
Console.WriteLine(" The expected revenue for this year is {0}. ", revenue.ToString("C"));

Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();

while (answer != QUIT)
{
if (answer.Equals("s"))
{
Console.WriteLine("Enter the names of singers(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
while (name != QUIT)
{
singingTotal += 1;
Console.WriteLine("Enter the names of singers: ");
name = Console.ReadLine().ToLower();
  
}
Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();
}
else if (answer.Equals("d"))
{
Console.WriteLine("Enter the names of dancer/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
while (name != QUIT)
{
dancingTotal += 1;
Console.WriteLine("Enter the names of dancer/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
  
}
Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();
}
else if (answer.Equals("m"))
{
Console.WriteLine("Enter the names of musical instrument player/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
while (name != QUIT)
{
mTotal += 1;
Console.WriteLine("Enter the names of musical instrument/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();

}
Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();
}
else if (answer.Equals("o"))
{
Console.WriteLine("Enter the names of other player/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
while (name != QUIT)
{
otherTotal += 1;
Console.WriteLine("Enter the names of other player/s(ZZZ to quit): ");
name = Console.ReadLine().ToLower();
}
Console.WriteLine("Enter the type of talent category(or enter 'zzz' to quit): ");
answer = Console.ReadLine().ToLower();
}
else
{
Console.Write("Invalid input, please enter again: ");
Console.WriteLine("Enter the type of talent category(S for singing, D for dancing, M for playing a musical instrument, or O for other): ");
answer = Console.ReadLine().ToLower();
}
}
constestantTotal = singingTotal + dancingTotal + mTotal + otherTotal;
Console.WriteLine("Summary");
Console.WriteLine("The total number of contestant: {0}", number2);
Console.WriteLine("The total number of players: {0}", constestantTotal);
Console.WriteLine("The total number of singers: {0}", singingTotal);
Console.WriteLine("The total number of dancers: {0}", dancingTotal);
Console.WriteLine("The total number of musical instrument players: {0}", mTotal);
Console.WriteLine("The total number of other players: {0}", otherTotal);

if (constestantTotal != number2)
{
Console.WriteLine("The number of constestant and number of players do not match, please try again.");
}

else
Console.WriteLine("The number of contestant and number of players match.");
int twice = 2 * number1;
if (number2 >= twice)
Console.WriteLine("The competition is more than twice as big this year");
else if (number2 < twice && number2 > number1)
Console.WriteLine("The competition is bigger than ever!");
else if (number2 <= number1)
Console.WriteLine("A tighter race this year! Come out and cast your vote!");
Console.ReadLine();
}
}
}