subject

In Chapter 7, 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: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
question
Computers and Technology, 22.06.2019 11:30
Write a function so that the main program below can be replaced by the simpler code that calls function original main program: miles_per_hour = float( minutes_traveled = float( hours_traveled = minutes_traveled / 60.0 miles_traveled = hours_traveled * miles_per_hour print('miles: %f' % miles_traveled) sample output with inputs: 70.0 100.0 miles: 116.666667
Answers: 3
question
Computers and Technology, 22.06.2019 20:40
Assume that there is a 4% rate of disk drive failure in a year. a. if all your computer data is stored on a hard disk drive with a copy stored on a second hard disk drive, what is the probability that during a year, you can avoid catastrophe with at least one working drive? b. if copies of all your computer data are stored on three independent hard disk drives, what is the probability that during a year, you can avoid catastrophe with at least one working drive?
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Consider the following function main: int main() { int alpha[20]; int beta[20]; int matrix[10][4]; . . } a. write the definition of the function inputarray that prompts the user to input 20 numbers and stores the numbers into alpha. b. write the definition of the function doublearray that initializes the elements of beta to two times the corresponding elements in alpha. make sure that you prevent the function from modifying the elements of alpha. c. write the definition of the function copyalphabeta that stores alpha into the first five rows of matrix and beta into the last five rows of matrix. make sure that you prevent the function from modifying the elements of alpha and beta. d. write the definition of the function printarray that prints any onedimensional array of type int. print 15 elements per line. e. write a c11 program that tests the function main and the functions discussed in parts a through d. (add additional functions, such as printing a two-dimensional array, as needed.)
Answers: 3
You know the right answer?
In Chapter 7, you modified the GreenvilleRevenue program to include a number of methods. Now modify...
Questions
question
Mathematics, 13.02.2020 11:42