Question

In: Computer Science

This is C# programming. In Chapter 2, you created an interactive application named GreenvilleRevenue. The program...

This is C# programming.

In Chapter 2, 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. 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!

Here's My 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, twiceLastYear;
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);
}
}

Solutions

Expert Solution

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

      }

   }

}

Let me know if you have any clarifications. Thank you...


Related Solutions

c# In Chapter 2, you created an interactive application named MarshallsRevenue. The program prompts a user...
c# In Chapter 2, you created an interactive application named MarshallsRevenue. The program prompts a user for the number of interior and exterior murals scheduled to be painted during the next month by Marshall’s Murals. Next, the programs compute the expected revenue for each type of mural when interior murals cost $500 each and exterior murals cost $750 each. The application also displays the total expected revenue and a statement that indicates whether more interior murals are scheduled than exterior...
In this programming assignment, you will implement a SimpleWebGet program for non- interactive download of files...
In this programming assignment, you will implement a SimpleWebGet program for non- interactive download of files from the Internet. This program is very similar to wget utility in Unix/Linux environment.The synopsis of SimpleWebGet is: java SimpleWebGet URL. The URL could be either a valid link on the Internet, e.g., www.asu.edu/index.html, or gaia.cs.umass.edu/wireshark-labs/alice.txt or an invalid link, e.g., www.asu.edu/inde.html. ww.asu.edu/inde.html. The output of SimpleWebGet for valid links should be the same as wget utility in Linux, except the progress line highlighted...
Intro C++ Programming Chapter 6 Functions You have been tasked to write a new program for...
Intro C++ Programming Chapter 6 Functions You have been tasked to write a new program for the Research Center's shipping department. The shipping charges for the center are as follows: Weight of Package (in kilograms)                Rate per mile Shipped 2 kg or less                                                      $0.05 Over 2 kg but no more than 6 kg    $0.09 Over 6 kg but not more than 10 kg    $0.12 Over 10 kg    $0.20 Write a function in a program that asks for...
Convert the MileConversions program to an interactive application. Instead of assigning a value to the miles...
Convert the MileConversions program to an interactive application. Instead of assigning a value to the miles variable, accept it from the user as input. class MileConversionsInteractive {    public static void main(String[] args) {       // Modify the code below       final double INCHES_IN_MILE = 63360;       final double FEET_IN_MILE = 5280;       final double YARDS_IN_MILE = 1760;       double miles = 4;       double in, ft, yds;       in = miles * INCHES_IN_MILE;       ft = miles * FEET_IN_MILE;       yds = miles * YARDS_IN_MILE;       System.out.println(miles + " miles...
C++ Programming: Programming Design and Data Structures Chapter 13 Ex 2 Redo Programming Exercise 1 by...
C++ Programming: Programming Design and Data Structures Chapter 13 Ex 2 Redo Programming Exercise 1 by overloading the operators as nonmembers of the class rectangleType. The header and implementation file from Exercise 1 have been provided. Write a test program that tests various operations on the class rectangleType. I need a main.cpp file Given: **************rectangleType.cpp******************** #include <iostream> #include <cassert> #include "rectangleType.h" using namespace std; void rectangleType::setDimension(double l, double w) { if (l >= 0) length = l; else length =...
Chapter 2, Problem 4E in An Introduction to Programming with C++ All of the employees at...
Chapter 2, Problem 4E in An Introduction to Programming with C++ All of the employees at Merks Sales are paid based on an annual salary rather than an hourly wage. However, some employees are paid weekly while others are paid every other week (biweekly). Weekly employees receive 52 paychecks; biweekly employees receive 26 paychecks. The payroll manager wants a program that displays two amounts: an employee’s weekly gross pay and his or her biweekly gross pay. Complete an IPO chart...
Write an interactive program in c++ that allows the user toenter 2-15 vectors (use the...
Write an interactive program in c++ that allows the user to enter 2-15 vectors (use the if statement). Display the resultant on the screen.
Write a Windows Form application named SumFiveInts. Microsoft Visual C#: An Introduction to Object-Oriented Programming,7th Edition....
Write a Windows Form application named SumFiveInts. Microsoft Visual C#: An Introduction to Object-Oriented Programming,7th Edition. Ch. 5, page 220. Take snip of program results.
Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
Design and implement an interactive program named trip.c that collects information about the user's car and...
Design and implement an interactive program named trip.c that collects information about the user's car and planned travel, and reports back useful information. The dialog below shows exactly what data should be collected as input and reported as output. Some Hints to get started /* Not tested not complete code Just to get you started */ #include /* FUNCTION PROTOTYPES */ void WelcomeMessage(); void AskUserForInput(); /* ask and check whether user wants to continue if wants to continue gather information...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT