You have decided to volunteer at your local history museum which sells tickets for admission. The museum curator has asked you to write a program that can help calculate the cost of one ticket for admission to the museum. Children under 6 are admitted for free, while all other children are charged $2.93 per ticket. Adults (18 and over) are charged $8.65 per ticket. All tickets that are not free have a convenience cost of $0.85, and all sales are subject to 10% sales tax (after the convenience fee is added). Furthermore, the owners want to offer an incentive of 20% off the price of a ticket when it is purchased on a weekday. The discount only applies to the price of the ticket, not to the convenience fee or sales tax. The program should allow the user to also input a day of the week as a word (e.g. Monday, Tuesday, etc.) which factors into the calculation of the cost of one ticket. Finally, display a wellformatted message that includes the age of the customer, cost of the ticket (with convenience fee and discount, if applicable), sales tax amount, and total cost including all fees and tax.
If at any time the user inputs an invalid value, the program should end with a message stating the user has entered an invalid value and the program should instruct the user to manually restart the program if they want to try again.
Questions:
1) Create a defining diagram that shows the input, processing, and output
2) Create a solution algorithm using pseudocode
3) Show testing using the desk checking table method, to include test data, expected results, and a desk checking table. Make sure your desk checking considers multiple cases including both valid and invalid test data to prove your algorithm will work in all cases
Editable code:
3) Program:
#include <stdio.h>
#include <string.h>
int main()
{
int age;
char day[15];
float tcost,concost=0.85,stax=0,disc=0,totcost=0;
while(1)
{
printf("\n Enter your age: ");
scanf("%d",&age);
if(age<0)
{
printf("ERROR: invalid value!!!");
break;
}
if(age>0 && age<6) tcost=0;
if(age>=6 && age <18) tcost=2.93;
if(age>=18) tcost=8.65;
printf("Enter day of the week: ");
scanf(" %s",day);
if(strcmp(day,"monday")==0 || strcmp(day,"tuesday")==0 || strcmp(day,"wednesday")==0 || strcmp(day,"thursday")==0 || strcmp(day,"friday")==0)
disc=tcost*0.2;
else if(strcmp(day,"saturday")==0 || strcmp(day,"sunday")==0)
disc=0;
else
{
printf("ERROR: invalid value!!!");
break;
}
printf("\n***TICKET***");
printf("\nAge: %d",age);
printf("\nCost of ticket: $%0.2f", tcost+concost-disc);
stax=(tcost+concost)*0.1;
printf("\nSale tax Amount: $%0.2f", stax);
totcost=tcost+concost-disc+stax;
printf("\nTotal cost: $%0.2f\n", totcost);
break;
}
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.