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 Chapter 4 of your book, you created an interactive application named MarshallsRevenue that prompts a...
In Chapter 4 of your book, you created an interactive application named MarshallsRevenue that prompts a user for the number of interior and exterior murals scheduled to be painted during a month and computes the expected revenue for each type of mural. The program also prompts the user for the month number and modifies the pricing based on requirements listed in Chapter 4. Now, modify the program so that the user must enter a month value from 1 through 12....
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...
For this computer assignment, you are to write and implement an interactive C++ program to find...
For this computer assignment, you are to write and implement an interactive C++ program to find and print all prime numbers, which are less than or equal to a given value of n, using the algorithm known as the Sieve of Eratosthenes. A prime number p is an integer greater than 1 that is divisible only by 1 and p (itself). The algorithm begins by initializing a set container to contain all the integers in the range 2 to n....
C Programming question: Develop a program named “sample” that prints the value of two functions: 1....
C Programming question: Develop a program named “sample” that prints the value of two functions: 1. Function f1 takes a single input argument of type int and returns the value of its input argument as float 2. Function f2 takes a single input argument of type char and returns an int. The output of f2 is the result of the sum of the values of the global variables, and the input argument minus the value of char ‘a’ plus the...
Java Program General Scenario: You are creating an interactive application that gets input from the keyboard...
Java Program General Scenario: You are creating an interactive application that gets input from the keyboard and keeps track of a grocery store that a businessman runs. In order to develop this application, you will be using 2 interfaces, 1 abstract class, and 1 concrete class. You should use the interfaces and the abstract class to create the concrete class. Your application should have overridden toString() at appropriate places so that you could display the object state, i.e., the string...
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 =...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT