Question

In: Computer Science

Modify the GreenvilleRevenue program so that it uses the Contestant class and performs the following tasks:...

Modify the GreenvilleRevenue program so that it uses the Contestant class and performs the following tasks: The program prompts the user for the number of contestants in this year’s competition; the number must be between 0 and 30. The program continues to prompt the user until a valid value is entered. The expected revenue is calculated and displayed. The revenue is $25 per contestant. For example if there were 3 contestants, the expected revenue would be displayed as: Revenue expected this year is $75.00 The program prompts the user for names and talent codes for each contestant entered. Along with the prompt for a talent code, display a list of the valid categories. The categories should be displayed in the following format: The types of talent are: S Singing D Dancing M Musical instrument O Other After data entry is complete, the program displays the valid talent categories and then continuously prompts the user for talent codes and displays the names of all contestants in the category. Appropriate messages are displayed if the entered code is not a character or a valid code.

beginning of c# code:

using System;

using static System.Console;

using System.Globalization;

class GreenvilleRevenue

{

   static void Main()

   {

      // Your code here

   }

}

Solutions

Expert Solution

/*
* C sharp program that prompts users to enter the number of participants.
* Then prompt for the names and talent codes from the user. If the user enters an invalid
* talent codes then reprompt for valid talent codes. Then display the names in
* Each category on the C# console window.
*/

//GreenvilleRevenue.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GreenvilleRevenue
{
class GreenvilleRevenue
{
static void Main(string[] args)
{
//Set constants and variabel names
const int COST_PER_CONTESTANT = 25;
int numParticipants = 0;
int revenue=0;
String talentCode = "";

//do-while loop
do
{
Console.Write("Enter # of participants : ");
//Read number of participants
int.TryParse(Console.ReadLine(), out numParticipants);

//Check valid range of partcipants
if (numParticipants < 0 || numParticipants > 30)
Console.WriteLine("Invalid number of particpant.");

} while (numParticipants < 0 || numParticipants > 30);

//Calculate the total revenue
revenue =numParticipants*COST_PER_CONTESTANT ;
Console.WriteLine("Revenue expected this year is ${0}", revenue.ToString("N2"));

//Create arrays of number of participants for names and talent codes
String[] names = new String[numParticipants];
String[] tcodes = new String[numParticipants];

//Loop to enter names and category codes
for (int index = 0; index < numParticipants ; index++)
{
//Read name of the particpant
Console.Write("Enter name of particpant : ");
//Read name
names[index] = Console.ReadLine();
//do-while loop
do
{
//Calling method, displayTalentCodes
displayTalentCodes();
talentCode = Console.ReadLine();
if (talentCode != "S" && talentCode != "D"
&& talentCode != "M" && talentCode != "O")
Console.WriteLine("Invalid talent code");
} while (talentCode!="S" && talentCode !="D"
&& talentCode !="M" &&talentCode != "O");

//Set talentCode to the tcodes at index
tcodes[index] = talentCode;
}//end of the for loop

Console.WriteLine("Singing category particpants :");
for (int index = 0; index < numParticipants; index++)
{
//Print Singing category names
if (tcodes[index] == "S")
Console.WriteLine("{0}", names[index]);
}
Console.WriteLine("\nDance category particpants :");
for (int index = 0; index < numParticipants; index++)
{
//Print Dance category names
if (tcodes[index] == "D")
Console.WriteLine("{0}", names[index]);
}
Console.WriteLine("\nMusic category particpants :");
for (int index = 0; index < numParticipants; index++)
{
//Print Music category names
if (tcodes[index] == "M")
Console.WriteLine("{0}", names[index]);
}
Console.WriteLine("\nOther category particpants :");
//Print Other category names
for (int index = 0; index < numParticipants; index++)
{
if (tcodes[index] == "O")
Console.WriteLine("{0}", names[index]);
}

Console.ReadKey();
}
/*Method, displayTalentCodes that display a menu of talent codes*/
public static void displayTalentCodes()
{
Console.WriteLine("S Singing");
Console.WriteLine("D Dancing");
Console.WriteLine("M Musical instrument");
Console.WriteLine("O Other");
} //end of the method, displayTalentCodes

} //end of the class,GreenvilleRevenue

}//end of the namespace

Sample output screenshot:


Related Solutions

Modify the program below so the driver class (Employee10A) uses a polymorphic approach, meaning it should...
Modify the program below so the driver class (Employee10A) uses a polymorphic approach, meaning it should create an array of the superclass (Employee10A) to hold the subclass (HourlyEmployee10A, SalariedEmployee10A, & CommissionEmployee10A) objects, then load the array with the objects you create. Create one object of each subclass. The three subclasses inherited from the abstract superclass print the results using the overridden abstract method. Below is the source code for the driver class: public class EmployeeTest10A { public static void main(String[]...
Finish the following java question:  Modify a Encryption program so that it uses the following encryption algorithm:...
Finish the following java question:  Modify a Encryption program so that it uses the following encryption algorithm: Every letter (both uppercase and lowercase) converted to its successor except z and Z, which are converted to 'a' and 'A' respectively (i.e., a to b, b to c, …, y to z, z to a, A to B, B to C, …, Y to Z, Z to A) Every digit converted to its predecessor except 0, which is converted to 9 (i.e., 9...
Write a program that performs the following two tasks in java Reads an arithmetic expression in...
Write a program that performs the following two tasks in java Reads an arithmetic expression in an infix form, stores it in a queue (infix queue) and converts it to a postfix form (saved in a postfix queue). Evaluates the postfix expression. Use linked lists to implement the Queue and Stack ADTs. DO NOT USE BUILT IN JAVA CLASSES
Modify the FeetInches class so that it overloads the following operators: <= >= != Demonstrate the...
Modify the FeetInches class so that it overloads the following operators: <= >= != Demonstrate the class's capabilities in a simple program. this is what needs to be modified // Specification file for the FeetInches class #ifndef FEETINCHES_H #define FEETINCHES_H #include <iostream> using namespace std; class FeetInches; // Forward Declaration // Function Prototypes for Overloaded Stream Operators ostream &operator << (ostream &, const FeetInches &); istream &operator >> (istream &, FeetInches &); // The FeetInches class holds distances or measurements...
Modify the Movie List 2D program -Modify the program so it contains four columns: name, year,...
Modify the Movie List 2D program -Modify the program so it contains four columns: name, year, price and rating (G,PG,R…) -Enhance the program so it provides a find by rating function that lists all of the movies that have a specified rating def list(movie_list): if len(movie_list) == 0: print("There are no movies in the list.\n") return else: i = 1 for row in movie_list: print(str(i) + ". " + row[0] + " (" + str(row[1]) + ")") i += 1...
Modify the partition.java program (Listing 7.2) so that the partitionIt() method always uses the highest-index (right)...
Modify the partition.java program (Listing 7.2) so that the partitionIt() method always uses the highest-index (right) element as the pivot, rather than an arbitrary number. (This is similar to what happens in the quickSort1.java program in Listing 7.3.) Make sure your routine will work for arrays of three or fewer elements. To do so, you may need a few extra statements. // partition.java // demonstrates partitioning an array // to run this program: C>java PartitionApp //////////////////////////////////////////////////////////////// class ArrayPar { private...
Modify the DetailedClockPane.java class in your detailed clock program, to add animation to this class. Be...
Modify the DetailedClockPane.java class in your detailed clock program, to add animation to this class. Be sure to include start() and stop() methods to start and stop the clock, respectively.Then write a program that lets the user control the clock with the start and stop buttons.
"4. (Modify) Modify Program 7.14 so that the user inputs the initial set of numbers when...
"4. (Modify) Modify Program 7.14 so that the user inputs the initial set of numbers when the program runs. Have the program request the number of initial numbers to be entered." //C++ Program 7.14 as follows #include #include #include #include using namespace std; int main() { const int NUMELS = 4; int n[] = {136, 122, 109, 146}; int i; vector partnums(n, n + NUMELS); cout << "\nThe vector initially has the size of " << int(partnums.size()) << ",\n and...
Modify the following 'MessageBoxes' application so it uses a single action listener for each button. This...
Modify the following 'MessageBoxes' application so it uses a single action listener for each button. This will require you to separate the single action listener logic into multiple listeners, one for each button. Then modify the code to provide additional options to two or more buttons. /* * The source code for this assignment started with * a sample from "Thinking in Java" 3rd ed. page 825 * by Bruce Eckel. I have finished adding the rest of the action...
You are required to modify the attached simulation program. This program currently uses an array to...
You are required to modify the attached simulation program. This program currently uses an array to implement the queue. You will modify the program so that it uses the STL queue instead. /* This is for CSC 611 class at NSU Computer Science Department This program is a modified C++ version of the C program From the Second Edition Simulation Modeling & Analysis Averill M. Law W. David Kelton */ #include using namespace std; #include #include double time = 0;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT