just asking for assistance with the menu items as they are set to uppercase M, R, C, X in the case statements how can this be modified to accept 'm' or 'M' as valid input.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace PracticalTest5
{
class Program
{
public static void Main(string[] args)
{
{
const int MIN_YEAR = 1888;
const int MAX_YEAR = 2011;
const int MIN_RATING = 0;
const int MAX_RATING = 5;
const float ACTING_PERCENTAGE = 0.25F;
const float MUSIC_PERCENTAGE = 0.15F;
const float CINEMATOGRAPHY_PERCENTAGE = 0.20F;
const float PLOT_PERCENTAGE = 0.30F;
const float DURATION_PERCENTAGE = 0.10F;
string movie_title = null;
int year_released = MIN_YEAR;
string publisher = " ";
float length = 0.0F;
int acting_rating = MIN_RATING;
int music_rating = MIN_RATING;
int cinematography_rating = MIN_RATING;
int plot_rating = MIN_RATING;
int duration_rating = MIN_RATING;
float overall_rating;
int star_count = 0;
string vTemp = "";
char response = ' ';
while (response != 'X')
{
Console.WriteLine();
Console.WriteLine("\nMOVIE INFORMATION!");
Console.WriteLine("\nM - INPUT MOVIE DETAILS");
Console.WriteLine("\nR - INPUT MOVIE RATINGS");
Console.WriteLine("\nC - CALCULATE & DISPLAY RATINGS");
Console.WriteLine("\nX - EXIT");
Console.Write("\nENTER YOUR CHOICE: ");
{
response = char.Parse(Console.ReadLine());
}
switch (response)
{
case 'M':
movie_title = null;
year_released = MIN_YEAR;
publisher = "";
length = 0.0F;
Console.WriteLine();
Console.Write("Movie Title : ");
movie_title = Convert.ToString (Console.ReadLine());
//year released: input and validation
bool Attempt = false;
while (Attempt == false)
{
Console.Write("Year Released (yyyy) : ");
vTemp = Console.ReadLine();
Attempt = Int32.TryParse(vTemp, out year_released);
Console.ForegroundColor = ConsoleColor.Red;
if (Attempt == false)
{
Console.WriteLine("Year released must be in numeric value. i.e 1987.");
}
else
{
if (year_released < MIN_YEAR)
{
Console.WriteLine("Year released must be after 1888.");
Attempt = false;
}
}
{
if (year_released > MAX_YEAR)
{
Console.WriteLine("Year released must be in or before current year.");
Attempt = false;
}
}
Console.ResetColor();
}
Console.Write("Publisher : ");
publisher = Convert.ToString(Console.ReadLine());
bool AttemptLength = false;
while (AttemptLength == false)
{
Console.Write("Length (hrs) : ");
vTemp = Console.ReadLine();
AttemptLength = float.TryParse(vTemp, out length);
if (AttemptLength == false)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Length must be a decimal number. i.e '2.5'.");
Console.ResetColor();
}
else
{
if (length <= 0)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Length must be more than '0' hours");
AttemptLength = false;
Console.ResetColor();
}
}
}
break;
case 'R':
acting_rating = MIN_RATING;
music_rating = MIN_RATING;
cinematography_rating = MIN_RATING;
plot_rating = MIN_RATING;
duration_rating = MIN_RATING;
Console.WriteLine("\nRatings (0 - 5)");
// Acting: Input & Validation (while loop)
bool Attempt1 = false;
while (Attempt1 == false)
{
Console.Write("\nActing : ");
vTemp = Console.ReadLine();
Attempt1 = Int32.TryParse(vTemp, out acting_rating);
if (Attempt1 == false)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Rating must be in numeric value between 0 and 5.");
Console.ResetColor();
}
else
{
if (acting_rating < MIN_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Minimum rating is '0'.");
Attempt1 = false;
Console.ResetColor();
}
}
{
if (acting_rating > MAX_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Maximum rating is '5'.");
Attempt1 = false;
Console.ResetColor();
}
}
}
// Music: Input & Validation (while loop)
bool Attempt2 = false;
while (Attempt2 == false)
{
Console.Write("Music : ");
vTemp = Console.ReadLine();
Attempt2 = Int32.TryParse(vTemp, out music_rating);
if (Attempt2 == false)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Rating must be in numeric value between 0 and 5.");
Console.ResetColor();
}
else
{
if (music_rating < MIN_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Minimum rating is '0'.");
Attempt2 = false;
Console.ResetColor();
}
}
{
if (music_rating > MAX_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Maximum rating is '5'.");
Attempt2 = false;
Console.ResetColor();
}
}
}
// Cinematography: Input & Validation (while loop)
bool Attempt3 = false;
while (Attempt3 == false)
{
Console.Write("Cinematography : ");
vTemp = Console.ReadLine();
Attempt3 = Int32.TryParse(vTemp, out cinematography_rating);
if (Attempt3 == false)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Rating must be in numeric value between 0 and 5.");
Console.ResetColor();
}
else
{
if (cinematography_rating < MIN_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Minimum rating is '0'.");
Attempt3 = false;
Console.ResetColor();
}
}
{
if (cinematography_rating > MAX_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Maximum rating is '5'.");
Attempt3 = false;
Console.ResetColor();
}
}
}
// Plot: Input & Validation (while loop)
bool Attempt4 = false;
while (Attempt4 == false)
{
Console.Write("Plot : ");
vTemp = Console.ReadLine();
Attempt4 = Int32.TryParse(vTemp, out plot_rating);
if (Attempt4 == false)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Rating must be in numeric value between 0 and 5.");
Console.ResetColor();
}
else
{
if (plot_rating < MIN_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Minimum rating is '0'.");
Attempt4 = false;
Console.ResetColor();
}
}
{
if (plot_rating > MAX_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Maximum rating is '5'.");
Attempt4 = false;
Console.ResetColor();
}
}
}
// Duration: Input & Validation (while loop)
bool Attempt5 = false;
while (Attempt5 == false)
{
Console.Write("Duration : ");
vTemp = Console.ReadLine();
Attempt5 = Int32.TryParse(vTemp, out duration_rating);
if (Attempt5 == false)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Rating must be in numeric value between 0 and 5.");
Console.ResetColor();
}
else
{
if (duration_rating < MIN_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Minimum rating is '0'.");
Attempt5 = false;
Console.ResetColor();
}
}
{
if (duration_rating > MAX_RATING)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Maximum rating is '5'.");
Attempt5 = false;
Console.ResetColor();
}
}
}
break;
case 'C':
if (length == 0)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("WARNING: MOVIE INPUT HAS NOT BEEN ENTERED");
Console.ResetColor();
}
if (acting_rating == 0)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("WARNING: RATINGS INPUT HAS NOT BEEN ENTERED");
Console.ResetColor();
}
else
{
// Calculate Overall Rating
// Print Output
Console.WriteLine("\n*************Movie Information*************");
Console.WriteLine("\nMovie Title : {0}", movie_title);
Console.WriteLine("Year released : {0}", year_released);
Console.WriteLine("Publisher : {0}", publisher);
Console.WriteLine("Length (hrs) : {0}", length.ToString("F1"));
Console.WriteLine("\n******************Ratings******************");
Console.WriteLine("\nActing : {0}", acting_rating);
Console.WriteLine("Music : {0}", music_rating);
Console.WriteLine("Cinematography : {0}", cinematography_rating);
Console.WriteLine("Plot : {0}", plot_rating);
Console.WriteLine("Duration : {0}", duration_rating);
overall_rating = ((ACTING_PERCENTAGE * acting_rating) + (MUSIC_PERCENTAGE * music_rating) + (CINEMATOGRAPHY_PERCENTAGE * cinematography_rating) + (PLOT_PERCENTAGE * plot_rating) + (DURATION_PERCENTAGE * duration_rating));
overall_rating = (overall_rating * 2);
overall_rating = (float)Math.Round(overall_rating, 0);
Console.Write("\nOverall Rating: {0:#}/10 ", overall_rating);
for (star_count = 0; star_count < overall_rating; )
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("*");
star_count = star_count + 1;
Console.ResetColor();
}
}
break;
case 'X':
default:
Console.WriteLine("\nUNKNOWN MENU SELECTION.");
break;
}
}
}
}
}
}