I need to write this code and the problem I am having is it is not giving me the correct total. I can not pinpoint where my mistake is and was wondering if someone can help me with this? Here is the question from my homework (My work is at the bottom):
Here is the information your program will ask the user to enter:
1. The number of lower bowl tickets he/she wants to buy.
2. The number of upper bowl tickets he/she wants to buy.
3. The number of games worth of tickets he/she wants to buy.
4. The sales tax in the locale in which the tickets are being bought, as a percentage.
Prompt the user to input these four values. You will output a single statement with the total cost of the football tickets.
Please define the following constants in your code:
#define LOWER_BOWL_TIX_PRICE 50.00
#define UPPER_BOWL_TIX_PRICE 25.00
Input Specification
1. The number of lower and upper bowl tickets will be integers in between 0 and 100, inclusive.
2. The number of games the user will be buying tickets for will be in between 0 and 7, inclusive.
3. The sales tax will be a real number percentage in between 0% and 20%
Sample Run
How many lower bowl seats do you want?
2
How many upper bowl seats do you want?
4
For many games do you want to buy these tickets?
5
What is the sales tax percentage in your locale?
6.5
The total cost of your football tickets is $1065.00.
__________________________________________________ _____________________
(MY WORK)
Code:
#include <stdio.h>
#define LOWER_BOWL_TIX_PRICE 50.00
#define UPPER_BOWL_TIX_PRICE 25.00
int main(void)
{
int lower, upper, games;
float sales_tax, tax, total, totala, totalb;
printf ("How many lower bowl seats do you want? \n");
scanf ("%d", &lower );
if (lower<0 || lower>100)
{
printf ("Invalid. Try Again. \n");
scanf ("%d", &lower );
}
printf ("How many upper bowl seats do you want? \n");
scanf ("%d", &upper );
if (upper<0 || upper>100)
{
printf ("Invalid. Try Again. \n");
scanf ("%d", &upper );
}
printf ("For how many games do you want to buy these tickets? \n");
scanf ("%d", &games );
if (games<0 || games>7)
{
printf ("Invalid. Try Again. \n");
scanf ("%d", &games );
}
printf ("What is the sales tax percentage in your locale? \n");
scanf ("%f", &tax );
if (tax<0 || tax>20)
{
printf ("Invalid. Try Again. \n");
scanf ("%d", &tax );
}
sales_tax = tax/100;
totala = (lower*50*games);
totalb = (upper*25*games);
total = (totala+totalb)* sales_tax;
printf ("The total cost of your football tickets? \n");
printf ("$%.2f", total );
getch ();
return 0;
}