Question: using System; using System.Globalization; class GreenvilleRevenue { static void Main ( ) { / / Declare variables to store user inputs int lastYearContestants, thisYearContestants; double

using System; using System.Globalization; class GreenvilleRevenue { static void Main(){// Declare variables to store user inputs int lastYearContestants, thisYearContestants; double revenue; // Get the number of contestants last year with input validation Console.Write("Enter number of contestants last year >>"); while (!int.TryParse(Console.ReadLine(), out lastYearContestants)){ Console.WriteLine("Invalid format - please enter a valid integer."); Console.Write("Enter number of contestants last year >>"); }// Get the number of contestants this year with input validation Console.Write("Enter number of contestants this year >>"); while (!int.TryParse(Console.ReadLine(), out thisYearContestants)){ Console.WriteLine("Invalid format - please enter a valid integer."); Console.Write("Enter number of contestants this year >>"); }// Display the number of contestants for both years Console.WriteLine("Last year's competition had {0} contestants, and this year's has {1} contestants", lastYearContestants, thisYearContestants); // Calculate and display the expected revenue for this year revenue = thisYearContestants *25.0; Console.WriteLine("Revenue expected this year is {0}", revenue.ToString("C", CultureInfo.GetCultureInfo("en-US"))); // Display a message indicating the competition is bigger than ever Console.WriteLine("The competition is bigger than ever!"); // Variables for talent counting and contestant names string contestantName, talentCode; int singingCount =0, dancingCount =0, instrumentCount =0, otherCount =0; // Get the contestant name with input validation Console.Write("Enter contestant name >>"); contestantName = Console.ReadLine(); while (true){// Display talent codes Console.WriteLine("Talent codes are:"); Console.WriteLine(" S Singing"); Console.WriteLine(" D Dancing"); Console.WriteLine(" M Musical instrument"); Console.WriteLine(" O Other"); // Get talent code with input validation Console.Write(" Enter talent code >>"); talentCode = Console.ReadLine(); char talent; // Validate talent code and update counts accordingly if (char.TryParse(talentCode, out talent)){ switch (talent){ case 'S': singingCount++; break; case 'D': dancingCount++; break; case 'M': instrumentCount++; break; case 'O': otherCount++; break; default: Console.WriteLine("That is not a valid code"); continue; }} else { Console.WriteLine("Invalid format - entry must be a single character"); continue; }// Get the contestant name with input validation Console.Write("Enter contestant name >>"); contestantName = Console.ReadLine(); // Display the types of talent and their counts Console.WriteLine("The types of talent are:"); Console.WriteLine("Singing {0}", singingCount); Console.WriteLine("Dancing {0}", dancingCount); Console.WriteLine("Musical instrument {0}", instrumentCount); Console.WriteLine("Other {0}", otherCount); // Get the talent type or allow the user to quit Console.Write("Enter a talent type or Z to quit >>"); talentCode = Console.ReadLine(); if (talentCode.ToUpper()=="Z") break; }}}

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 Programming Questions!