Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Char to Uppercase From User Inputted Data

I am trying to create a program for a hotel where the user is to enter a character (either S, D, or L) and that is supposed to correspond with a code further down the line. I need help converting the user input (no matter what way they enter it) to be converted to uppercase so I can then use an if statement to do what I need to do. My code so far is the following:

public static void Main()
{
    int numdays;
    double total = 0.0;
    char roomtype, Continue;

    Console.WriteLine("Welcome to checkout. We hope you enjoyed your stay!");

    do
    {
        Console.Write("Please enter the number of days you stayed: ");
        numdays = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("S = Single, D = Double, L = Luxery");
        Console.Write("Please enter the type of room you stayed in: ");
        roomtype = Convert.ToChar(Console.ReadLine());


     **^Right Her is Where I Want To Convert To Uppercase^**

        total = RoomCharge(numdays,roomtype);
        Console.WriteLine("Thank you for staying at our motel. Your total is: {0}", total);

        Console.Write("Do you want to process another payment? Y/N? : ");
        Continue = Convert.ToChar(Console.ReadLine());


    } while (Continue != 'N');

    Console.WriteLine("Press any key to end");
    Console.ReadKey();
}

public static double RoomCharge(int NumDays, char RoomType)
{
    double Charge = 0;

    if (RoomType =='S')
        Charge = NumDays * 80.00;

    if (RoomType =='D')
        Charge= NumDays * 125.00;

    if (RoomType =='L')
        Charge = NumDays * 160.00;

    Charge = Charge * (double)NumDays;
    Charge = Charge * 1.13;

    return Charge;
} 
like image 287
user3418316 Avatar asked Mar 14 '14 04:03

user3418316


2 Answers

Try default ToUpper method.

roomtype = Char.ToUpper(roomtype);

Go through this http://msdn.microsoft.com/en-us/library/7d723h14%28v=vs.110%29.aspx

like image 52
Ajay Avatar answered Sep 23 '22 02:09

Ajay


roomtype = Char.ToUpper(roomtype);
like image 30
Sean B Avatar answered Sep 26 '22 02:09

Sean B