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...
Q1. Write an application that performs each of the following tasks: a) Specify that class “Pieceworker”...
Q1. Write an application that performs each of the following tasks: a) Specify that class “Pieceworker” inherits from class Employee. b) Create instance variables “Firstname” and “ID” in superclass and a toString to display. c) Add “branch” and toString in PieceWorker. d) Show overriding to display the variables of the subclass. Q2 Draw an inheritance hierarchy for students at a university. Use Student as the superclass of the hierarchy, and then extend Student with classes Undergraduate Student and Graduate Student....
Modify the Encryption program so that it uses the following encryption algorithm: Every letter (both uppercase...
Modify the 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 to 8, 8 to...
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
Write a program that performs the following two tasks: Reads an arithmetic expression in an infix...
Write a program that performs the following two tasks: 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 the algorithms described in class/ lecture notes. Use linked lists to implement the Queue and Stack ADTs. Using Java built-in classes will result in 0 points. You must use your own Stack and Queue classes (my code is a...
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...
You should write a small C++ program that performs the following tasks: First, your program should...
You should write a small C++ program that performs the following tasks: First, your program should read in a set of 5 integers from “standard in” (remember cin). The numbers that you read in will be either zero or positive. If at least one of the five numbers entered is non-zero then your program should calculate the sum of the numbers and report that back to the user using “standard output” (remember cout). Then your program should be ready to...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT