Thanks for the help. I was able to get the calculations in the program right. The old coding I had for it doesnt really work like it did before. Basically I'm trying to have it where the numbers I put in show an error if the number entered is greater than 999 and also show an error if it is a non number aswell. Also trying to see how I can make the information in yearly show only when I type in yearly or "Y" and the information for daily only show when I type in daily or "D". This is the current code I have atm.
#include
#include
#include
#include
void PrintAStarLine(void);
void GetInput(void);
void Tickets(void);
float price( const float item ){
int piece = 0;
char newline2;
scanf( "%d%c", &piece, &newline2 );
return item * piece;
}
char newline;
char customerName[30];
char tickettype[];
char TicketNumber[] = "D, d";
int main( void )
{
PrintAStarLine();
printf(" Home Aquarium Data Entry \n");
printf("\n\n");
PrintAStarLine();
GetInput();
Tickets();
const float DChild = 1.50;
float DailyChild = 0.00;
const float YChild = 5.50;
float YearlyChild = 0.00;
float TotalChild;
const float DAdult = 2.00;
float DailyAdult = 0.00;
const float YAdult = 6.50;
float YearlyAdult = 0.00;
float TotalAdult;
const float DSenior = 1.25;
float DailySenior = 0.00;
const float YSenior = 3.75;
float YearlySenior = 0.00;
float TotalSenior;
printf("#of Children for daily tickets: " );
fflush( stdout );
DailyChild = price( DChild );
printf("\n\n");
printf("#of Children for yearly tickets: " );
fflush( stdout );
YearlyChild = price( YChild );
printf("\n\n");
printf("#of Adults for daily tickets: " );
fflush( stdout );
DailyAdult = price( DAdult );
printf("\n\n");
printf("#of Adults for yearly tickets: " );
fflush( stdout );
YearlyAdult = price( YAdult );
printf("\n\n");
printf("#of Seniors for daily tickets: " );
fflush( stdout );
DailySenior = price( DSenior );
printf("\n\n");
printf("#of Seniors for yearly tickets: " );
fflush( stdout );
YearlySenior = price( YSenior );
system("pause");
printf("\n\n\n");
TotalChild = (DailyChild + YearlyChild);
TotalAdult = (DailyAdult + YearlyAdult);
TotalSenior = (DailySenior + YearlySenior);
printf( "Children Total Cost: $%6.2f\n", TotalChild );
printf("\n");
printf( "Adult Total Cost: $%6.2f\n", TotalAdult );
printf("\n");
printf( "Senior Total Cost: $%6.2f\n", TotalSenior );
printf("\n");
return 0;
}
void PrintAStarLine(void)
{
printf("**************************************************************************** \n");
printf("\n\n");
return;
}
void GetInput(void)
{
printf("Customer Name (First Middle Last): ");
scanf( "%[^\n]%c", customerName, &newline );
printf("\n\n\n");
return;
}
void Tickets(void)
{
printf("\n\nType of ticket (Daily(D) or Yearly(Y): ");
scanf(" %s", &TicketNumber);
if(strcmp(TicketNumber,"D")==0)
{
printf("#of Children for daily tickets: " ); ;
}
else if(strcmp(TicketNumber,"d")==0)
{
;
}
else if(strcmp(TicketNumber,"Daily")==0)
{
;
}
else if(strcmp(TicketNumber,"daily")==0)
{
;
}
else if(strcmp(TicketNumber,"Y")==0)
{
;
}
else if(strcmp(TicketNumber,"y")==0)
{
;
}
else if(strcmp(TicketNumber,"Yearly")==0)
{
;
}
else if(strcmp(TicketNumber,"yearly")==0)
{
;
}
else
{
printf("\n Incorrect Ticket Number Entered, please try again! \n");
printf("\n");
Tickets();
}
printf("\n");
return;
}