Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE *outfile;
char ch, name;
float fee, discfee;
outfile = fopen("flightinfo.txt","r");
if (outfile = NULL)
{
printf("Record not found!\n");
exit(1);
}
printf("Enter the name of passenger for ticket fee discount: ");
scanf("%s", &name);
if (fee >= 15000.00)
discfee = fee * 0.80;
else if (fee >= 10000.00)
discfee = fee * 0.85;
else if (fee >= 5000.00)
discfee = fee * 0.90;
else
discfee = fee * 0.95;
printf("The ticket fee after discount is $%8.2f\n", discfee);
return 0;
}
BELOW is extract from the txt file:
Louis
CJ777
4578.00
New York
London
2016 11 1
Economy
1
Tom
DL992
3824.00
New York
Tokyo
2016 12 1
Economy
1
I want to calculate the ticket fee after discount from original fee in the txt file, but I have trouble with the codes up there. Please tell me how to do it. Thanks.