VitzzViperzz
Well-known member
Hello,
So I am making an application that checks to see if the person buying fuel will be paying in cash or buying premium fuel for discounts.
I have got as far as collecting all of the information, but I just cannot check to see if both booleans are equal to true.
Here is the code:
I did try this:
but it says that your local variables haven't been used and it assumes that the user has answered yes to both questions.
I did do some searching on the internet, but I really cannot find anything.
Any feedback welcome.
Thanks
So I am making an application that checks to see if the person buying fuel will be paying in cash or buying premium fuel for discounts.
I have got as far as collecting all of the information, but I just cannot check to see if both booleans are equal to true.
Here is the code:
C#:
Console.WriteLine("Welcome to Mo's gas station.");
Console.WriteLine("Will you be paying with cash?");
bool payingCash = false;
string userInput1 = Console.ReadLine().ToLower();
if (userInput1 == "yes" || userInput1 == "y")
{
payingCash = true;
Console.WriteLine("Awesome, you're paying in cash!");
}
else
Console.WriteLine("Will you be buying premium gas?");
bool premiumGas = false;
string userInput2 = Console.ReadLine().ToLower();
if (userInput2 == "yes" || userInput2 == "yes")
{
premiumGas = true;
Console.WriteLine("That's great, you're buying premium gas!");
}
if (payingCash && premiumGas = true)
{
Console.WriteLine("You're entiteld to 10% discount!");
}
else
{
Console.WriteLine("Thank you for shopping us. No discounts have applied this time. ");
}
I did try this:
C#:
if ((payingCash) && (premiumGas = true))
but it says that your local variables haven't been used and it assumes that the user has answered yes to both questions.
I did do some searching on the internet, but I really cannot find anything.
Any feedback welcome.
Thanks