Untitled
unknown
csharp
3 years ago
6.2 kB
8
Indexable
using System;
using System.Collections.Generic;
using static System.Console;
using System.Globalization;
class GreenvilleRevenue
{
public static List<string> Singers = new List<string>();
public static List<string> Dancers = new List<string>();
public static List<string> Musicians = new List<string>();
public static List<string> Others = new List<string>();
public static int SingingAmount;
public static int DancingAmount;
public static int MusicalInstrumentAmount;
public static int OtherAmount;
public static int ExpectedRevenue;
public static int PreviousYearContestants;
public static int CurrentYearContestants;
static void Main()
{
// Get previous year contestant count
GetPreviousYearCount();
// Get current year contestant count
GetCurrentYearCount();
// Calculate Expected Revenue
CalculateExpectedRevenue();
// Print Expected Revenue
PrintExpectedRevenue();
// Print Comment/Contestant population flavor text
PrintComment();
// Ask for contestant names and roles
GatherContestants();
// Output the types of talent
PrintTalent();
}
static void CalculateExpectedRevenue() => ExpectedRevenue = CurrentYearContestants * 25;
public static void DisplayRelationship(int numThisYear, int numLastYear)
{
// Write your DisplayRelationship() here.
}
static void GatherContestants()
{
for (int i = 0; i < CurrentYearContestants; i++)
{
// Ask for contestant name
var name = ReadLine();
// Ask for role
var role = GetRole(name);
if (role == "Z")
break;
}
sentinel:
var sentinel = ReadLine();
if (sentinel != "S" && sentinel != "D" && sentinel != "M" && sentinel != "O")
{
if (sentinel != "Z")
WriteLine($"{sentinel} is not a valid code.");
}
if (sentinel != "Z")
goto sentinel;
}
/// <summary>
/// This method gets and returns a valid number of contestants and is called twice once for last year’s number of contestants and once for this year’s value
/// </summary>
/// <param name="when"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <returns></returns>
public static int GetContestantNumber(string when, int min, int max)
{
getprevious:
// Get number
PreviousYearContestants = int.Parse(ReadLine());
// Validate number
if (PreviousYearContestants < 0 || PreviousYearContestants > 30)
{
WriteLine("Enter a valid number");
goto getprevious;
}
getcurrent:
// Get number
CurrentYearContestants = int.Parse(ReadLine());
// Validate number
if (CurrentYearContestants < 0 || CurrentYearContestants > 30)
{
WriteLine("Enter a valid number");
goto getcurrent;
}
return 0;
}
public static void GetContestantData(int numThisYear, string[] names, char[] talents, char[] talentCodes, string[] talentCodesStrings, int[] counts)
{
// Write your GetContestantData() here.
}
public static void GetLists(int numThisYear, char[] talentCodes, string[] talentCodesStrings, string[] names, char[] talents, int[] counts)
{
// Write your GetLists() here.
}
static string GetRole(string name)
{
var role = ReadLine();
if (role != "S" && role != "D" && role != "M" && role != "O")
{
WriteLine($"{role} is not a valid code.");
GetRole(name);
}
switch (role)
{
case "S":
SingingAmount++;
Singers.Add(name);
break;
case "D":
DancingAmount++;
Dancers.Add(name);
break;
case "M":
MusicalInstrumentAmount++;
Musicians.Add(name);
break;
case "O":
OtherAmount++;
Others.Add(name);
break;
}
return role;
}
static void PrintExpectedRevenue() => WriteLine("Expected revenue: {0}", ExpectedRevenue.ToString("C", CultureInfo.GetCultureInfo("en-US")));
static void PrintComment()
{
if (CurrentYearContestants > PreviousYearContestants * 2)
{
WriteLine("This competition is more than twice as big this year!");
}
else if (CurrentYearContestants > PreviousYearContestants)
{
WriteLine("The competition is bigger than ever!");
}
else if (CurrentYearContestants < PreviousYearContestants)
{
WriteLine("A tighter race this year! Come out and cast your vote!");
}
}
static void PrintTalent()
{
WriteLine("The types of talent are:");
WriteLine($"Singing {SingingAmount}");
WriteLine($"Dancing {DancingAmount}");
WriteLine($"Musical Instrument {MusicalInstrumentAmount}");
WriteLine($"Other {OtherAmount}");
//
WriteLine("Contestants with talent Musical Instrument are:");
foreach (var musician in Musicians)
{
WriteLine(musician.ToString());
}
WriteLine("Contestants with talent Dancing are:");
foreach (var dancer in Dancers)
{
WriteLine(dancer.ToString());
}
WriteLine("Contestants with talent Singing are:");
foreach (var singer in Singers)
{
WriteLine(singer.ToString());
}
WriteLine("Contestants with talent Other are:");
foreach (var other in Others)
{
WriteLine(other.ToString());
}
}
}
Editor is loading...