here is my sourc code.
I have one question.
is there anyway I can set the total(),for not allowing any purchase more than $500.00.
Code:
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
double getfloat(double lower);
double total(int qty, double money);
double show(double ticket_price,int number_of_tickets);
/* ========================================================================== */
int main()
{
double ticket_price;
double number_of_tickets;
char choice;
clrscr();
do
{
printf("\nEnter the ticket price between(5 or greater than 5): ");
ticket_price=getfloat(5);
printf("\nEnter the number of tickets: ");
number_of_tickets=getfloat(1);
show(ticket_price, number_of_tickets);
printf("\nContinue (Y/N): ");
while(getchar() != '\n');
scanf("%c", &choice);
}
while (choice == 'Y' || choice == 'y');
getchar();
return 0;
}
/* ========================================================================== */
double getfloat(double lower)
{
double number;
scanf("%lf",&number);
while (number < lower)
{
printf("Illegal value %lf; please re-enter a value : ",
number,lower);
scanf("%lf",&number);
}
return(number);
}
/* ========================================================================== */
double total(int qty, double money)
{
return qty*money;
}
/* ========================================================================== */
double show(double ticket_price, int number_of_tickets)
{
double total_owed;
printf("The ticket price is -->$%.2lf\n", ticket_price);
printf("The number of tickets is ----> %d\n", number_of_tickets);
total_owed=total(ticket_price, number_of_tickets);
printf("Total owed --------> $%.2lf\n", total_owed);
return 0;
}
/* ========================================================================== */
Code tags added by Kermi3