Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

I need help with my if statement, truly don't know what I did wrong

+3 votes
asked Nov 4, 2022 by Ricky Quintana (150 points)
https://onlinegdb.com/Y91YZO0Pi

The price of the show stays the same, even when I enter "y" for the $20 shirt. I dont understand why

1 Answer

0 votes
answered Nov 4, 2022 by Peter Minarik (86,040 points)

Let's consider your code segment. Look at the comments I added to your code.

cout << "Welcome to the Lake Cuyamaca Art Show!" << endl;
rate = cuyamacaRate; // initial value of rate is cuyamacaRate
if (shirt=='y')
{
    rate += 20; // rate is increased by 20
}
if (shirt == 'n')
{
    rate; // this is an empty instruction, nothing happens here. Probably this is wrong.
}
event = " Lake Cuyamaca";
cout << "The cost for admission is $" << cuyamacaRate << endl; // You print the cuyamacaRate, not the rate, that is the adjusted value.

Now, it should be clear why the wrong value is printed.

This applies to many of your switch-cases.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...