6

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;
} 
S.R.I
  • 1,860
  • 14
  • 31
user3418316
  • 69
  • 1
  • 1
  • 2

3 Answers3

11

Try default ToUpper method.

roomtype = Char.ToUpper(roomtype);

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

Ajay
  • 6,418
  • 18
  • 79
  • 130
3
roomtype = Char.ToUpper(roomtype);
Sean B
  • 11,189
  • 3
  • 27
  • 40
0
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());
    roomtype = Char.ToUpper(roomtype);   

    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();
}