Code:
#include <stdio.h>
#include <stdlib.h>
void printMovieListing (char* am, int* d3);
void sellTickets(char am, int d3, int* c, float* d);
void getPayment(float price, int ratetype);
#define ADULTRATE 8.50f
#define STUDENTRATE 5.00f
#define CISRATE 3.00f
int main (void)
{
float price;
char am;
int d3, ratetype;
printMovieListing (&am, &d3);
sellTickets(am, d3, &ratetype, &price);
getPayment(price, ratetype);
system("pause");
return 0;
}
void printMovieListing (char* am, int* d3)
{
int hour, min, choice, threeD;
char a;
printf("Current Movies Shown:\n");
printf("1. The Eagle\n");
printf("2. The Green Hornet\n");
printf("3. The Green Hornet 3d\n");
printf("4. Tron: Legacy\n");
printf("5. Sanctum\n");
printf("6. Sanctum 3d\n");
printf("Your Selection [1-6]: ");
scanf("%d", &choice);
if(choice==3 || choice==6)
{
printf("11:35am, 2:30pm, 5:25pm, 8:05pm, 10:50pm\n");
threeD = 0;
}
else
{
printf("9:35am, 12:30pm, 3:25pm, 6:05pm, 8:50pm\n");
threeD = 1;
}
*d3 = threeD;
printf("Enter a Time [example: 2:45pm]: ");
scanf("%d:%d%c", &hour, &min, &a);
*am = a;
return;
}
void sellTickets(char am, int d3, int* c, float* d)
{
int adult, student, cis, tickets, ratetype;
float total;
printf("%c", am);
printf("%d", d3);
printf("Number of Adult Tickets: ");
scanf("%d", &adult);
printf("Number of Student Tickets: ");
scanf("%d", &student);
printf("Number of CIS 15AG Students Tickets: ");
scanf("%d", &cis);
tickets = adult + student + cis;
printf("That will be %d tickets.\n", tickets);
if(d3 == 0)
{
if(am == 'a')
{
total = ((ADULTRATE+1)*adult) + ((STUDENTRATE+1)*student) + ((CISRATE+2)*cis);
ratetype = 3;
}
else
{
total = ((ADULTRATE+2)*adult) + ((STUDENTRATE+2)*student) + ((CISRATE+2)*cis);
ratetype = 2;
}
}
else
{
if(am == 'a')
{
total = ((ADULTRATE-1)*adult) + ((STUDENTRATE-1)*student) + ((CISRATE)*cis);
ratetype = 1;
}
else
{
total = ((ADULTRATE)*adult) + ((STUDENTRATE)*student) + ((CISRATE)*cis);
ratetype = 0;
}
}
*c = ratetype;
*d = total;
return;
}
void getPayment(float price, int ratetype)
{
float payment, credit;
switch(ratetype)
{
case 0: printf("Standard Rate\n");
printf("Adult: $%2.2f, Student $%2.2f, CIS15AG Student $%2.2f\n", ADULTRATE, STUDENTRATE, CISRATE);
break;
case 1: printf("Morning Discount\n");
printf("Adult: $%2.2f, Student $%2.2f, CIS15AG Student $%2.2f\n", (ADULTRATE-1), (STUDENTRATE-1), CISRATE);
printf("No Morning Discount for CIS15AG Sudents who should be in class.\n");
break;
case 2: printf("Standard 3D Rate\n");
printf("Adult: $%2.2f, Student $%2.2f, CIS15AG Student $%2.2f\n", (ADULTRATE+2), (STUDENTRATE+2), (CISRATE+2));
break;
case 3: printf("Morning 3D Discount\n");
printf("Adult: $%2.2f, Student $%2.2f, CIS15AG Student $%2.2f\n", (ADULTRATE+1), (STUDENTRATE+1), (CISRATE+2));
printf("No Morning Discount for CIS15AG Sudents who should be in class.\n");
break;
}
printf("Enter your payment: $");
scanf("%f", &payment);
if(payment > price)
{
credit = payment - price;
printf("You have a credit of: $%2.2f\n", credit);
printf("Please pick up your tickets at will call.\n");
}
else if(payment < price)
{
credit = price - payment;
printf("Your ticket cost is $%2.2f more than your payment\n", credit);
printf("Guess you will have to wait till the DVD release.\n");
}
else
printf("Please pick up your tickets at will call.\n");
return;
}