i need a suggestion of a way to make this code look better
Code:
#include <stdio.h>
// Function Declarations
void getData(int* days, double* airfare, double* ground, double* rate, double* food, double* enter);
void calctotal(int days, double airfare, double ground, double rate, double food, double enter, double* totalF, double* totalR, double* total);
void calcsubtotal(int days, double rate, double food, double* totalFood, double* totalRate);
void output(int days, double airfare, double ground, double rate, double food, double enter, double totalF, double totalR, double total);
int main(void)
{
//Local Declarations
int days;
double airfare;
double ground;
double rate;
double food;
double enter;
double totalF;
double totalR;
double total;
double subtotal;
// Statements
getData(&days, &airfare, &ground, &rate, &food, &enter);
calctotal(days, airfare, ground, rate, food, enter, &totalF, &totalR, &total);
output(days, airfare, ground, rate, food, enter, totalF, totalR, total);
return 0;
}// main
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void getData(int* days,double* airfare, double* ground, double* rate, double* food, double* enter)
{
printf("how many days: ");
scanf("%d", days);
printf("How much is the airfare: ");
scanf("%lf", airfare);
printf("How much is the ground fare: ");
scanf("%lf", ground);
printf("How much is the hotel rate: ");
scanf("%lf", rate);
printf("How much is the food price: ");
scanf("%lf", food);
printf("How much is the cost of entertainment: ");
scanf("%lf", enter);
return;
}// getData
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void calctotal(int days, double airfare, double ground, double rate, double food, double enter, double* totalF, double* totalR, double* total)
{
double totalFood;
double totalRate;
calcsubtotal(days, rate, food, &totalFood, &totalRate);
*total = totalFood + totalRate + airfare + ground + enter;
*totalF = totalFood;
*totalR = totalRate;
return;
}//calctotal
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void calcsubtotal(int days, double rate, double food, double* totalFood, double* totalRate)
{
*totalFood = days * food;
*totalRate = (days - 1) * rate;
return;
}//calcsubtotal
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void output(int days, double airfare, double ground, double rate, double food, double enter, double totalF, double totalR, double total)
{
printf("\nDays: %d\n", days);
printf("Airfare: %.2lf\n", airfare);
printf("Ground Transportations: %.2lf\n", ground);
printf("Hotel: %.2lf\n", totalR);
printf("Food: %.2lf\n", totalF);
printf("Entertainment: %.2lf\n", enter);
printf("\n");
printf("Total: %.2lf\n\n", total);
return;
}//output
this is what i was being asked to do
Write a program to calculate the total cost of your Spring break trip.
Enter the number of days, airfare, amount needed for ground transportation,
nightly hotel rate (includes taxes), allotment per day for food, and cost of entertainment.
Use a function for input, a function to calculate totals which calls a function to calculate subtotals.
This function will be invoked once per item: hotel, food.
i finished the code but for some reason the caltotal and subtotal function doesn't seem right, also im a bit confuse of a way to call function subtotal from function caltotal