i have to make program for a hotel (just a scenario) but i'm having problems.
First i have to ask them to choose a room type i.e A/B/C/D which decides how much their room costs per night (a=$22, b=$55 etc). Then i have to ask how many nights they wish to stay then i ask if they're members and if they answer 'y' then they get a 30% discount. Then I display the price.
I tried using switch statements but it didn't really work so i tried if statements, it ended up looking something like this:
..............................................................................................
char roomType, member;
int howManyNights, cost,costWithDiscount;
if(roomType=='a')
console.write("how many nights would you like to stay");
howManyNights=convert.ToChar(console.ReadLine());
cost= howManyNights *22;
costWithDiscount= cost - (cost%30);
console.writeline("are you a member?");
member=convert.ToChar(Console.ReadLine());
if (member == 'y')
console.WriteLine("cost:${0}", costWithDiscount);
if (member == 'n')
console.WriteLine("cost:${0}", cost);
if(roomType=='b')
console.write("how many nights would you like to stay");
howManyNights=convert.ToChar(console.ReadLine());
cost= howManyNights *55;
costWithDiscount= cost - (cost%30);
console.writeline("are you a member?");
member=convert.ToChar(Console.ReadLine());
if (member == 'y')
console.WriteLine("cost:${0}", costWithDiscount);
if (member == 'n')
console.WriteLine("cost:${0}", cost);
etc...
.......................................................................................
its something like that. 'a' always gives me the right costs but 'b' and the others never give me the discount price when i say i'm a member, they just give me the price WITHOUT the discount.
I'm so confused, i thought i was understanding c#, when i read through the code it makes sense to me but its just not working, very frustrating!
I'd appreciate any help, thanks!