Question

In: Computer Science

The program prompts a user for the number of contestants entered in this year’s and last...

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.

Solutions

Expert Solution

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");

      }

   }

}


Related Solutions

Write a program in C that prompts the user for a number of seconds and then...
Write a program in C that prompts the user for a number of seconds and then converts it to h:m:s format. Example: 5000 seconds should display as 1:23:20 (1 hour, 23 minutes, 20 seconds.) Test with several values between about 100 seconds and 10,000 seconds. use unint and remainders for this and keep it as simple as possible.
Write a C++ program that finds the minimum number entered by the user .The user is...
Write a C++ program that finds the minimum number entered by the user .The user is allowed to enter negative numbers 0, or positive numbers. The program should be controlled with a loop statement. Break statements is not allowed to break from loop. After each number inputted by the user, The program will prompt user if they need to enter another number. User should enter either Y for yes or N for no. Make Sure the user enters either Y...
IN C++ Write a program that prompts the user to enter the number of students and...
IN C++ Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score (display the student’s name and score). Also calculate the average score and indicate by how much the highest score differs from the average. Use a while loop. Sample Output Please enter the number of students: 4 Enter the student name: Ben Simmons Enter the score: 70 Enter the student name:...
Write a JAVA program that prompts the user for the number of names they’d like to...
Write a JAVA program that prompts the user for the number of names they’d like to enter. Create a new array of the size chosen by the user and prompt the user for each of the names. Output the list of names in reverse order.
Write a program that prompts the user to enter a number within the range of 1...
Write a program that prompts the user to enter a number within the range of 1 to 10 inclusive • The program then generates a random number using the random class: o If the users guess is out of range use a validation loop (DO) to repeat the prompt for a valid number o If the users guess matches the random number tell them they win! o If the users guess does not match the random number tell them they...
Write a program in c++ that prompts the user to input a coin collection of number...
Write a program in c++ that prompts the user to input a coin collection of number of quarters, dimes, nickels and pennies. The program should then convert the coin collection into currency value as dollars. The coin values should all be whole numbers and the resulting currency value should be displayed with two decimals. An example of user interaction is as follows: Coin Convertor Enter number of quarters: 3 Enter number of dimes: 1 Enter number of nickels: 4 Enter...
Java Programming Create a program that prompts the user for an integer number and searches for...
Java Programming Create a program that prompts the user for an integer number and searches for it within an array of 10 elements. What is the average number of comparisons required to find an element in the array? Your program should print the number of comparisons required to find the number or determine that the number does not exist. Try finding the first and last numbers stored in the array. Run your program several times before computing the average.
Write a program that prompts the user to enter a number within the range of 1...
Write a program that prompts the user to enter a number within the range of 1 to 10 inclusive • The program then generates a random number using the random class: o If the users guess is out of range use a validation loop (DO) to repeat the prompt for a valid number o If the users guess matches the random number tell them they win! o If the users guess does not match the random number tell them they...
In Java: Write a program that prompts the user to enter a positive number until the...
In Java: Write a program that prompts the user to enter a positive number until the user input a negative number. In the end, the program outputs the sum of all the positive numbers. You should use do-while loop (not while, not for). You cannot use break or if statement in the lab. Hint: if the program adds the last negative number to your sum, you can subtract the last number from the sum after the loop.
Python A program which prompts the user to enter an number which is a integer n...
Python A program which prompts the user to enter an number which is a integer n and creates a tuple where the values are all numbers between 1 and n (both inclusive). Note: you can assume that the integer will always be > 1. Input Result 3 Enter an integer: 3 (1, 2, 3)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT