How do I calculate the totals of the car park values as stated below:
Make a C program to help manage a parking lot For this procedure the following was reported:
- For each car you should be informed of the license plate, the number of hours you have been in the parking lot
- At the start of the parking opening, the amount to be charged per hour must be established
- It is known that parking has 30 boxes
- At the end of the day a report should be generated where you should have the car plate, the number of hours parked and the amount to be charged to each vehicle. you should also be informed of the total value of the parking box.
I managed to do it to some extent .. but I'm stuck at the time of displaying the final values .. how do I calculate the final value of the total ?? which formula?
follow my code below:
#include<stdio.h>
#include<math.h>
#include<conio.h>
main(void){
int i, qtdCarro, hora[i];
char placa[i][256];
float valorHora, valor, total;
printf("Valor por hora: ");
scanf("%f", &valorHora);
fflush(stdin);
printf("Numero de carros: ");
scanf("%d", &qtdCarro);
fflush(stdin);
if(qtdCarro > 30){
printf("O Estacionamento so possui 30 vagas");
return 0;
} else {
for (i=1; i<= qtdCarro ; i++){
printf("Placa do veiculo %d: ", i);
scanf("%s", &placa[i]);
fflush(stdin);
printf("Horas do veiculo %d: ", i);
scanf("%d", &hora[i]);
fflush(stdin);
}
for (i=1 ; i <= qtdCarro; i++){
valor = hora[i] * valorHora;
printf("Veiculo da placa %s ficou %d horas e gastou %f reais \n", placa[i], hora[i], valor);
}
printf("Valor total gasto no estacionamento e de: %f \n", total);
}
}