Code:
#include <stdio.h>
/*This is a program to report the charges incurred for each day, and after all days are processed, the total duration for each level, the total charges for the period, the average charge per person trained in that period, and the day, level, amount of the lowest day in that period*/
float prd_chrg; /*total charges per period*/
int day_dur; /*total number of minutes of training session per day*/
int lvl_a_dur; /*Duration, per period that level A was trained*/
int lvl_b_dur; /*Duration, per period that level A was trained*/
int lvl_i_dur; /*Duration, per period that level A was trained*/
int low; /*used to set the lowest day, level and charge of a period*/
int client_num; /*Client ID number*/
int mnth; /*Month*/
int yr; /*Year*/
int day; /*Day number*/
int day_dur; /*Total number of minutes of training session per day*/
char lvl; /*Level trained on a given day*/
int num_ppl; /*Number of people per group*/
int ppl_ovr_4; /*Number of people over four in a group*/
float lvl_chrg; /*Charge per person for a given level*/
int count; /*Total number of people trained per period*/
float avg_chrg; /*Average charge per day during a period*/
char more_client; /*Used to determine if there is more client data to input*/
int low_day; /*This is the day number of the day with the lowest charge in the period*/
char low_lvl; /*This is the level that was trained on the day with the lowest charge in the period*/
float low_chrg; /*This is the lowest day charge of the period*/
float day_chrg; /*This is the charge for the day the data was entered for*/
float dsct_chrg; /*This is the price per person over 4 in a group*/
float lvl_chrg; /*This is the charge for the level trained on a given day*/
float lvl_i_chrg; /*This is the amount charged for training level I*/
float lvl_a_chrg; /*This is the amount charged for training level A*/
float lvl_b_chrg; /*This is the amount charged for training level B*/
/*Functions*/
void initialize (void);
void input_prd (void);
void input_day (void);
void update_avg (void);
void output_prd (void);
void more_client (void);
void update_lvl_chrg (void);
void input_people (void);
void update_chrg (void);
void update_low (void);
void output_day (void);
int main (void)
{
init ();
input_prd ();
do
{
input_day ();
}while (day<=15);
update_avg ();
output_prd ();
more_client ();
return 0;
}
void initialize (void)
/*This function initializes certain variables*/
{
prd_chrg==0;
day_dur==0;
lvl_a_dur==0;
lvl_b_dur==0;
lvl_i_dur==0;
low==999999999;
}
void input_prd (void)
/*This function allows the user to input the month, year, and client the data is for*/
{
printf("\nInput client number: ");
scanf("%d", &client_num);
printf("\nInput month: ");
scanf("%d", &mnth);
printf("\nInput year: ");
scanf("%d", &yr);
}
void input_day (void)
/*This function allows the user to input the day of the month, duration of the training for a given day, and the number of people trained*/
{
printf("\nInput day number: ");
scanf("%d", &day);
printf("\nInput day duration: ");
scanf("%d", &day_dur);
fflush(stdin);
printf("\nInput the day's level (A, I, B): ");
scanf("%c", &lvl);
printf("\nInput number of people trained: ");
scanf("%d", &num_ppl);
update_lvl_chrd ();
input_people ();
if (num_ppl<=4)
{
num_ppl==4;
}
else
{
ppl_ovr_4=num_ppl-4;
num_ppl==4;
}
update_chrg ();
update_low ();
output_day ();
}
void update_lvl_chrg (void)
/*This function determines what the hourly charge for a given day was and calculates the level duration to that point in the period*/
{
if (lvl=='I')
{
lvl_chrg==1.5;
dsct_chrg==.75;
lvl_i_chrg=(lvl_i_chrg+day_dur);
}
else
{
if (lvl=='B')
{
lvl_chrg==1;
dsct_chrg==.5;
lvl_b_chrg=(lvl_b_chrg+day_dur);
}
else
{
if (lvl=='A')
{
lvl_chrg==2;
dsct_chrg==1;
lvl_a_chrg=(lvl_a_chrg+day_dur);
}
}
}
}
void input_people (void)
/*This function allows the user to input the number of people trained on a given day*/
{
printf("\nInput number of people in a group: ");
scanf("%d", num_ppl);
count=(count+num_ppl);
}
void update_chrg (void)
/*This function calculates the charge for a given day*/
{
day_chrg=((lvl_chrg*num_ppl*day_dur)+(dsct_chrg*ppl_ovr_4*day dur));
prd_chrg=(prd_chrg=day_chrg);
}
void update_low (void)
/*This function updates the low charge, day, and level of the period*/
{
if (day_chrg<low)
{
day_chrg=low_chrg;
low_day=low;
low_lvl=lvl;
}
}
void output_day (void)
/*This function outputs day of the month and that day's charge*/
{
printf("\nDay number: %d", day);
printf("\nDay charge: %f", day_chrg);
}
void update_avg (void)
/*This function calculates the average amount charged per person in the period*/
{
avg_chrg=(prd_chrg/count);
}
void output_prd (void)
/*This function outputs the total level durations, period charge, day number, day charge for the last day of the period, and the lowest day, charge, and level of the period*/
{
printf("\nLevel A duration: %d", lvl_a_dur);
printf("\nLevel I duration: %d", lvl_i_dur);
printf("\nLevel B duration: %d", lvl_b_dur);
printf("\nPeriod charge: %f", prd_chrg);
printf("\nDay number: %d", day);
printf("\nDay charge: %f", day_chrg);
printf("\nAverage charge: %f", avg_chrg);
printf("\nLow charge: %f", low_chrg);
printf("\nLow day: %d", low_day);
printf("\nLow level: %c", low_lvl);
}
void more_client (void)
/*This function allows the user to input whether or not they need to input data for more clients*/
{
fflush (stdin);
printf("Are there more clients to enter? (Y, N) ");
scanf("%c", &more_client);
if (more_client=='y')
{
input_prd ();
}
}
The problem comes at the end. When I try to compile, I get the following errors