954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

accept lower case or uppercase in c#

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;
                    }
                }
            }
        }
    }
}
pivotcity
Newbie Poster
13 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

Copy the code from Case 'M'.
And add this below that case:

Case 'm':
//Code From Case 'M'
break;
jmurph333
Light Poster
36 posts since Apr 2011
Reputation Points: 10
Solved Threads: 4
 

You can convert the response variable from Char to a String using the ToString() method and then use the ToUpper() method of the String class on the response variable in the switch which makes sure that anything you enter is converted to upper case so if you enter either "m" or "M" it's going to be converted to "M", for example:

using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            char response = 'm';
            while (response != 'X')
            {
                switch (response.ToString().ToUpper())
                {
                    // Make sure "M" is in double quotes
                    case "M":
                        Console.WriteLine("You Entered m or M");
                        response = 'X';
                        break;
                    default:
                        break;
                }
            }
            Console.ReadLine();
        }
    }
}


or you can make the response variable a String instead of Char (if it is not required to be Char) and then use the ToUpper() method of the String class directly, for example:

using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            // Notice "response" is now a string and uses
            // double quotes instead of single quotes
            string response = "m";
            while (response != "X")
            {
                switch (response.ToUpper())
                {
                    // Make sure "M" is in double quotes
                    case "M":
                        Console.WriteLine("You Entered m or M");
                        response = "X";
                        break;
                    default:
                        break;
                }
            }
            Console.ReadLine();
        }
    }
}


Note:
ToUpper() is a method of the String class that converts a string from lower case to upper case.
" " double quotes represent a String
' ' single quotes represent a Char

Or you can use the approach indicated in the previous post, I'm not sure which one is better.

codes4f0x0d
Newbie Poster
7 posts since Jul 2011
Reputation Points: 13
Solved Threads: 5
 

will this require me to change the bool 'value' names in the case 'm' as it states its already defined.

pivotcity
Newbie Poster
13 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

thanks codes4f0x0d
i went with

using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            // Notice "response" is now a string and uses
            // double quotes instead of single quotes
            string response = "m";
            while (response != "X")
            {
                switch (response.ToUpper())
                {
                    // Make sure "M" is in double quotes
                    case "M":
                        Console.WriteLine("You Entered m or M");
                        response = "X";
                        break;
                    default:
                        break;
                }
            }
            Console.ReadLine();
        }
    }
}


and everything works except for the X, do i have my code in the wrong order?

string 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 = (Console.ReadLine());
                    }
                    


                    switch (response.ToString().ToUpper())
                    {
pivotcity
Newbie Poster
13 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

The order is fine. But what do you mean when you say "everything works except for the X", you mean lower case x doesn't work? If that's the case then in the while loop you can check for two conditions upper case X and lower case x

while (response != "X" || response != "x")


Also if you declared response as a String then you don't need to use the ToString() method in the switch statement, just use ToUpper() directly since response is already a string.

switch (response.ToUpper())


Also why are you enclosing this line in its own separate block?
Is there a reason why you're doing that?

{
    response = Console.ReadLine();
}
codes4f0x0d
Newbie Poster
7 posts since Jul 2011
Reputation Points: 13
Solved Threads: 5
 

You could also just use the fallthrough on the case statement:

switch (response) {
    case 'm':
    case 'M':
        // code here
        break;
    etc...
}


And you have way to much code in your case statements. Make those methods.

Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

Thanks for the help everyone,

its now accepting lower and uppercase for cases 'm' 'r' and 'c'
But its still not accepting an input for 'X' or 'x'. it just returns to the menu again, any assistance?

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)
        {
            
                bool ratings_entered = false;
                bool movie_details_entered = false;
                
                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 = "";
                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' || 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':
                        case 'm':

                            while (movie_details_entered == false)
                            {
                                movie_title = "";
                                year_released = MIN_YEAR;
                                publisher = "";
                                length = 0.0F;

                                // Movie Title: Input & Validation (while loop)


                                Console.WriteLine();
                                Console.Write("Movie Title : ");
                                vTemp = 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 || year_released > MAX_YEAR)
                                        {
                                            Console.WriteLine("Year released must be after 1888.");
                                            Attempt = false;
                                        }
                                    }

                                    Console.ResetColor();
                                }

                                // Publisher: Input & Validation (while loop)
                                Console.Write("Publisher : ");
                                publisher = Convert.ToString(Console.ReadLine());

                                // Length: Input & Validation (while loop)
                                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();
                                        }
                                    }
                                }

                                movie_details_entered = true;
                            }

                            break;

                        case 'R':
                        case 'r':

                            while (ratings_entered == false)
                            {
                                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 || acting_rating > MAX_RATING)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.WriteLine("Minimum rating is '0'.");
                                            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 || music_rating > MAX_RATING)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.WriteLine("Minimum rating is '0'.");
                                            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 || cinematography_rating > MAX_RATING)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.WriteLine("Minimum rating is '0'.");
                                            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 || plot_rating > MAX_RATING)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.WriteLine("Minimum rating is '0'.");
                                            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 || duration_rating > MAX_RATING)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.WriteLine("Minimum rating is '0'.");
                                            Attempt5 = false;
                                            Console.ResetColor();
                                        }
                                    }
                                }

                                ratings_entered = true;
                            }

                            break;
                        case 'C':
                        case 'c':

                            if (ratings_entered == false)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("WARNING: RATINGS INPUT HAS NOT BEEN ENTERED");
                                Console.ResetColor();
                            }
                            
                            if (movie_details_entered == false)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("WARNING: MOVIE 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':
                        case 'x':

                        default:
                            Console.WriteLine("\nUNKNOWN MENU SELECTION.");
                            break;
                    }
                  
                }
            }
        }
    }
}
pivotcity
Newbie Poster
13 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

Line 45: Change the or (||) to an and {&&).

Right now if it's 'X' it's not 'x' so the or is true. Reverse is also true :)

Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

legend!

cheers for the help im only in week 5 of uni so it means a lot. but somehow everytime i change something, there is something else that goes wrong. i assume as im still new this is common.

If i enter the ratings, and try to enter them again it will not allow me and will keep looping the menu.
also if i select 'c' from menu item WITHOUT entering the rating first it will generate the Error message but will still print results instead of going back to menu.

I dont know, its midnight where i am, maybe i just need some sleep. haha

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)
        {
                            {
                    bool ratings_entered = false;
                    bool movie_details_entered = false;
                
                
                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 = "";
                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' && 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':
                            case 'm':
                                {
                                    movie_title = "";
                                    year_released = MIN_YEAR;
                                    publisher = "";
                                    length = 0.0F;

                                    // Movie Title: Input & Validation (while loop)
                                    Console.WriteLine();
                                    Console.Write("Movie Title : ");
                                    vTemp = 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 || year_released > MAX_YEAR)
                                            {
                                                Console.WriteLine("Year released must be after 1888.");
                                                Attempt = false;
                                            }
                                        }

                                        Console.ResetColor();
                                    }

                                    // Publisher: Input & Validation (while loop)
                                    Console.Write("Publisher : ");
                                    publisher = Convert.ToString(Console.ReadLine());

                                    // Length: Input & Validation (while loop)
                                    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();
                                            }
                                        }
                                    }

                                    movie_details_entered = true;
                                }

                                break;

                            case 'R':
                            case 'r':
                                {
                                    while (ratings_entered == false)
                                    {
                                        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 || acting_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    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 || music_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    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 || cinematography_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    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 || plot_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    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 || duration_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    Attempt5 = false;
                                                    Console.ResetColor();
                                                }
                                            }
                                        }

                                        ratings_entered = true;
                                    }
                                }

                                break;
                            case 'C':
                            case 'c':

                                if (ratings_entered == false)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("WARNING: RATINGS INPUT HAS NOT BEEN ENTERED");
                                    Console.ResetColor();
                                }

                                if (movie_details_entered == false)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("WARNING: MOVIE 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':
                            case 'x':

                            default:
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nUNKNOWN MENU SELECTION.");
                                Console.ResetColor();
                                break;
                        }
                    }
                }
            }
        }
    }
}
pivotcity
Newbie Poster
13 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

OK. I have made some changes. The only thing that happens now is:
if no movie data is entered, but the ratings are it will generate the error message
if movie data is enetered, but the ratings are not it will print results.

so i assume it has something to do with the case 'C' statement

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)
        {
            {
                bool ratings_entered = false;
                bool movie_details_entered = false;
                
                
                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 = "";
                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' && 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':
                            case 'm':
                                {
                                    movie_title = "";
                                    year_released = MIN_YEAR;
                                    publisher = "";
                                    length = 0.0F;

                                    // Movie Title: Input & Validation (while loop)
                                    Console.WriteLine();
                                    Console.Write("Movie Title : ");
                                    vTemp = 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 || year_released > MAX_YEAR)
                                            {
                                                Console.WriteLine("Year released must be after 1888.");
                                                Attempt = false;
                                            }
                                        }

                                        Console.ResetColor();
                                    }

                                    // Publisher: Input & Validation (while loop)
                                    Console.Write("Publisher : ");
                                    publisher = Convert.ToString(Console.ReadLine());

                                    // Length: Input & Validation (while loop)
                                    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();
                                            }
                                        }
                                    }

                                    movie_details_entered = true;
                                }

                                break;

                            case 'R':
                            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 || acting_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    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 || music_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    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 || cinematography_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    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 || plot_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    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 || duration_rating > MAX_RATING)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("Minimum rating is '0'.");
                                                    Attempt5 = false;
                                                    Console.ResetColor();
                                                }
                                            }
                                        }

                                        ratings_entered = true;
                                    }
                                }

                                break;
                            case 'C':
                            case 'c':

                                if (ratings_entered == false)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("WARNING: RATINGS INPUT HAS NOT BEEN ENTERED");
                                    Console.ResetColor();
                                }

                                if (movie_details_entered == false)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("WARNING: MOVIE 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':
                            case 'x':

                            default:
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\nUNKNOWN MENU SELECTION.");
                                Console.ResetColor();
                                break;
                        }
                    }
                }
            }
        }
    }
}
pivotcity
Newbie Poster
13 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

As Momerath, 1st go and do some cleanUp of your code. Use methods and call them from the case, that will make bugtracing and error finding much easier.

But just imlement and METHOD to check if all data has been entred, if not stop and prompt error message to say that data is missing.

Singlem
Light Poster
49 posts since Feb 2010
Reputation Points: 10
Solved Threads: 8
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: