128k views
0 votes
You created an interactive application named GreenvilleRevenue. 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. Using the program you wrote in Case Study 1 of Chapter 2, 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!
Grading
When you have completed your program, click the Submit button to record your score.
Code:
using System;
using static System.Console;
class GreenvilleRevenue
{
static void Main()
{
int last, curr;
while(true) {
Console.WriteLine("Enter the number of contestants entered in last year's competition : ");
last = Int32.Parse(Console.ReadLine());
if(last < 0 || last > 30) {
Console.WriteLine("Error. Please enter a value between 0 and 30.");
} else {
break;
}
}
while(true) {
Console.WriteLine("Enter the number of contestants entered in this year's competition : ");
curr = Int32.Parse(Console.ReadLine());
if(curr < 0 || curr > 30) {
Console.WriteLine("Error. Please enter a value between 0 and 30.");
} else {
break;
}
}
if((last >= 0) && (last <= 30) && (curr >= 0) && (curr <= 30))
Console.WriteLine("The revenue expected for this year's competition : $" + curr * 25 + '\\');
if (curr > last * 2)
Console.WriteLine("The competition is more than twice as big this year!\\");
else
if (curr > last && curr <= (last * 2))
Console.WriteLine("The competition is bigger than ever!\\");
else
if (curr < last)
Console.WriteLine("A tighter race this year! Come out and cast your vote!\\");
else
Console.WriteLine("Please enter a valid value\\");
Console.ReadLine();
}
}

User Nico Burns
by
3.5k points

2 Answers

9 votes

Answer:Console.WriteLine("Enter the number of contestants in last year's competition: ");

int lastYearContestants = int.Parse(Console.ReadLine());

Console.WriteLine("Enter the number of contestants in this year's competition: ");

int thisYearContestants = int.Parse(Console.ReadLine());

Console.WriteLine("Last year's competition had " + lastYearContestants + " contestants" + ", and this year's has " + thisYearContestants + " contestants.");

int revenue = thisYearContestants * 25;

Console.WriteLine("Revenue expected this year is $" + revenue + ".00");

if (thisYearContestants > lastYearContestants)

Console.WriteLine("It is True that this year's competition is bigger than last year's.");

else

Console.WriteLine("It is False that this year's competition is bigger than last year's");

Step-by-step explanation:

This will out put the correct sentences and gives the revenue in the correct format.

User Wasilikoslow
by
3.7k points
11 votes

Answer:

Step-by-step explanation:

The program in this code is written correctly and has the messages applied in the code. Therefore, the only thing that would need to be done is pass the correct integers in the code. If you pass the integer 100 contestants for last year and 300 for current year. Then these inputs will provide the following output as requested in the question.

The competition is more than twice as big this year!

This is because the current year would be greater than double last years (100 * 2 = 200)

User Vikko
by
3.7k points