In: Computer Science
The program prompts a user for the number of contestants entered in this year’s and last year’s Greenville Idol competition, and then it displays the revenue expected for this year’s competition if each contestant pays a $25 entrance fee.
The programs also display a statement that compares the number of contestants each year. Now, replace that statement with one of the following messages:
If the competition has more than twice as many contestants as last year, display The competition is more than twice as big this year!
If the competition is bigger than last year’s but not more than twice as big, display The competition is bigger than ever!
If the competition is smaller than last year’s, display, A tighter race this year! Come out and cast your vote!
Below is the source code.
using System;
using static System.Console;
class GreenvilleRevenue
{
static void Main()
{
const int ENTRANCE_FEE = 25;
string entryString;
int numThisYear;
int numLastYear;
int revenue;
bool isThisYearGreater;
Write("Enter number of contestants
last year >> ");
entryString = ReadLine();
numLastYear =
Convert.ToInt32(entryString);
Write("Enter number of contestants
this year >> ");
entryString = ReadLine();
numThisYear =
Convert.ToInt32(entryString);
revenue = numThisYear *
ENTRANCE_FEE;
isThisYearGreater = numThisYear >
numLastYear;
WriteLine("Last year's competition
had {0} contestants, and this year's has {1} contestants",
numLastYear,
numThisYear);
WriteLine("Revenue expected this
year is {0}", revenue.ToString("C"));
WriteLine("It is {0} that this
year's competition is bigger than last year's.",
isThisYearGreater);
}
}
Please show output and source code of how to get the displayed text.
If you have any doubts, please give me comment...
using System;
using static System.Console;
class GreenvilleRevenue {
static void Main () {
const int ENTRANCE_FEE = 25;
string entryString;
int numThisYear;
int numLastYear;
int revenue;
Write ("Enter number of contestants last year >> ");
entryString = ReadLine ();
numLastYear = Convert.ToInt32 (entryString);
Write ("Enter number of contestants this year >> ");
entryString = ReadLine ();
numThisYear = Convert.ToInt32 (entryString);
revenue = numThisYear * ENTRANCE_FEE;
WriteLine ("Last year's competition had {0} contestants, and this year's has {1} contestants", numLastYear, numThisYear);
WriteLine ("Revenue expected this year is {0}", revenue.ToString ("C"));
if (numThisYear >= numLastYear * 2)
WriteLine ("The competition is more than twice as big this year!\n");
else {
if (numThisYear > numLastYear)
WriteLine ("The competition is bigger than ever!\n");
else
WriteLine ("A tighter race this year! Come out and cast your vote!\n");
}
}
}