I am doing an extra assignment for my CSCI class. The assignment asks to create a program that calculates hours for customers in a parking garage. i wrote my program out and now i am trying to break it down into custom functions. i was doing fine until i got to te function to clculate total. It's not returning total when i run the program it just prints zero. can anyone help here is my code.
#include <stdio.h>
void PrintHeading(void);
void printvalues (int,int,float);
float calctotal (float);
int main (void)
{
int cnt=0;//counter
int hours;//hours
float total=0;//Total amount to pay
char choice;//user choice for continuing
int array1[10][2] = {0}; // holding customer number and hours
float array2[10]={0};// holding customer total
int row = 0, column = 0;
//array indices
do{
//Assigning customer number
cnt++;
//accepting # of hours
printf("Please enter number of hours:");
scanf("%d", &hours);
calctotal(total);
PrintHeading();
printf("\n");
//print heading
//storing customer info into array
array1[row][column++] = cnt;
array1[row][column] = hours;
array2[row] = total;
row++;
column = 0;
printvalues(cnt,hours,total);
printf("\n\n");
printf("\nWould you like to continue? y for yes n for no.\n");
scanf("%*c%c", &choice);
printf("\n");
}while(choice == 'y'|| choice == 'Y');
return 0;
}
void PrintHeading(void)
{
printf("\n\n%s%10s%15s", "Customer Number", "Hours", "Total Charge");
}
void printvalues (int cnt,int hours,float total)
{
printf("%d%21d%10c%-10.2f", cnt, hours,'$', total);
}
float calctotal(float total)
{
int hours=0;
if (hours < 3 && hours > 0)
total = 2;
else
if (hours >= 19 && hours <= 24)
total = 10;
else
if (hours>3 && hours < 19)
total = (hours-3) * .5 + 2;
else
if (hours > 24){
printf("invalid input......try again!\n");
scanf("%d",&hours);
}
return total;
}