subject

You modified the GreenvilleRevenue program to include a number of methods. Now modify every data entry statement to use a TryParse() method to ensure that each piece of data is the correct type. Any invalid user entries should generate an appropriate message, and the user should be required to reenter the data. using System;
using static System. Console;
class GreenvilleRevenue
{
static void Main(string[] args)
{
const int fee = 25;
int lastYearsContestants;
int thisYearsContestants;
const int LOW = 0;
const int HIGH = 30;
int other = 0;
int dancer = 0;
int musician = 0;
int singer = 0;
WriteLine("");
WriteLine("* The stars shine in Greenville. *");
WriteLine("");
WriteLine("");
lastYearsContestants = getContestantsNum(message, LOW, HIGH);
string[] contestant = new string[thisYearsContestants];
string[] talent = new string[thisYearsContestants];
getContestantsInfo(contestant, talent);
for (int x = 0; x < talent. Length; ++x)
{
if (talent[x] == "O")
{
++other;
}
else if (talent[x] == "S")
{
++singer;
}
else if (talent[x] == "D")
{
++dancer;
}
else if (talent[x] == "M")
{
++musician;
}
}
Clear();
WriteLine("Currently signed up, there are..");
WriteLine("{0} dancers", dancer);
WriteLine("{0} singers", singer);
WriteLine("{0} musicians", musician);
WriteLine("{0} everything else!", other);
contestantByTalent(contestant, talent);
Clear();
contestantInfo(thisYearsContestants , lastYearsContestants, fee);
}
static int getContestantsNum(string message, int LOW, int HIGH)
{
WriteLine("Please enter the number of contestants for last year.>>");
string input = ReadLine();
int contestantsNum = Convert. ToInt32(input);
while (contestantsNum < LOW || contestantsNum > HIGH)
{
WriteLine("Valid numbers are 0 through 30, Please try again.>>");
contestantsNum = Convert. ToInt32(ReadLine());
}
return contestantsNum;
WriteLine("Please enter the number of contestants for this year.>>");
string input = ReadLine();
int contestantsNum = Convert. ToInt32(input);
while (contestantsNum < LOW || contestantsNum > HIGH)
{
WriteLine("Valid numbers are 0 through 30, Please try again.>>");
contestantsNum = Convert. ToInt32(ReadLine());
}
return contestantsNum;
}
static string getTalent(int contestantsNum)
{
bool correct = false;
string talentType = "";
while (!correct)
{
WriteLine("What is contestant " + contestantsNum + "'s skill? Please enter 'S' for Singer, 'D' for Dancer, 'M' for " +
"Musician, 'O' for Other.>>");
talentType = ReadLine().ToUpper();
if (talentType == "S" || talentType == "D" || talentType == "M" || talentType == "O")
{
correct = true;
}
else
{
WriteLine("Please enter a valid response.>>");
}
}
return talentType;
}
static void contestantByTalent(string[] contestant, string[] talent)
{
WriteLine ("To see a list of all contestants with a specific talent, Please enter a talent code. talent codes are(S)inger, (D)ancer, (M)usician, (O)ther; altenatively, you may type (E) to exit.>>");
string entry = ReadLine().ToUpper();
while (entry != "E")
{
if (entry != "S" && entry != "D" && entry != "M" && entry != "O")
{
WriteLine("That wasn't a valid talent code. Valid talent codes are (S)inger, (D)ancer, (M)usician, (O)ther; altenatively, you may type (E) to exit.>>");
entry = ReadLine().ToUpper();
if (entry == "E")
break;
}
for (int x = 0; x < talent. Length; ++x)
{
if (entry == talent[x])
WriteLine("Contestant " + contestant[x] + " talent " + talent[x]);
}
WriteLine("To see a list of all contestants with a specific talent, Please enter a talent code. talent codes are (S)inger, (D)ancer, (M)usician, (O)ther; altenatively, you may type (E) to exit.>>");
entry = ReadLine().ToUpper();
}
}
static void getContestantsInfo(string[] contestant, string[] talent)
{
for (int x = 0; x < contestant. Length; ++x)
{
WriteLine("What is the name for Contestant " + (x + 1) + "?");
contestant[x] = ReadLine();
talent[x] = getTalent(x + 1);
}
}
static void contestantInfo (int thisYearsContestants, int lastYearsContestants, int fee)
{
if (thisYearsContestants > lastYearsContestants * 2)
{
WriteLine("The competition is more than twice as big this year!");
WriteLine("The expected revenue for this year's competition is {0:C}", (thisYearsContestants * fee));
}
else
if (thisYearsContestants > lastYearsContestants && thisYearsContestants <= (lastYearsContestants * 2))
{
WriteLine("The competition is bigger than ever!");
WriteLine("The expected revenue for this year's competition is {0:C}", (thisYearsContestants * fee));
}
else
if (thisYearsContestants < lastYearsContestants)
{
WriteLine("A tighter race this year! Come out and cast your vote!");
WriteLine("The expected revenue for this year's competition is {0:C}.", (thisYearsContestants * fee));
}
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:00
Are special characters that allow you to search for multiple words at the same time.
Answers: 2
question
Computers and Technology, 22.06.2019 13:00
We as humans write math expression in infix notation, e.g. 5 + 2 (the operators are written in-between the operands). in a computer’s language, however, it is preferred to have the operators on the right side of the operands, i.e. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix.write a program that takes an “infix” expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % (example infix expression: (7 - 3) / (2 + 2)postfix expression: 7 3 - 2 2 + /result: 1guidelines: 1. you will need to use stacks in three placesa. one for the parenthesis check [char stack]b. one during infix to postfix [char stack]c. one during evaluation [int stack]for a and b above, you can use same array and same push, pop method as both ofthem are char. but for evaluation you have int stack and you might consider to createanother push pop method to handle it. maybe push_int, pop_int, etc. or find otherstrategy to utilize existing push pop method2. you can create a function for obtaining operator priority. that function should take anoperator as input and return its priority as an integer. this function will you a lot andreduce repeated code3. during evaluation you will need to convert char into integer. example for single digit: char c = '5'; int x = c - '0';
Answers: 2
question
Computers and Technology, 22.06.2019 15:30
In a compound condition, both conditions on either side of the logical operator and must be true for the overall condition to be true. a: true b: false
Answers: 1
question
Computers and Technology, 22.06.2019 22:00
During physical science class ben and jerry connected three identical lightbulbs in parallel to a battery where happens when ben removes one of the lightbulbs from it’s socket
Answers: 2
You know the right answer?
You modified the GreenvilleRevenue program to include a number of methods. Now modify every data ent...
Questions
question
Mathematics, 16.02.2021 15:40
question
Mathematics, 16.02.2021 15:50
question
Chemistry, 16.02.2021 15:50
Questions on the website: 13722362