Question: In C#, I am asked to modify my code to add this additional line of code: In Chapter 4, you created an interactive application named

In C#, I am asked to modify my code to add this additional line of code: In Chapter 4, you created an interactive application named GreenvilleRevenue that prompts a user for the number of contestants entered in this years and last years Greenville Idol competition and displays the revenue expected for this years com- petition if each contestant pays a $25 entrance fee. The program also displays one of three appropriate statements specified in the case problem in Chapter 4, based on a comparison between the number of contestants this year and last year. Now, modify the program so that the user must enter a number between 0 and 30, inclusive, for the number of contestants each year. If the user enters an incorrect number, the program prompts for a valid value.

The code I have so far is :

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace GreenvilleRevenue { class Program { static void Main(string[] args)

{ Console.WriteLine("Enter the number of contestants entered in last year's competition : "); int last = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter the number of contestants entered in this year's competition : "); int curr = Int32.Parse(Console.ReadLine());

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(); } } }

But I cannot get it to read in the new IF statment and operate correctly.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!