0
How do I calculate the totals of car parking values as stated below:
Do a C program to assist in the administration of a parking lot For this procedure the following has been informed:
- for each car must be informed the plate, the amount of hours that stayed in the parking
- at the beginning of the opening of the parking must be established the amount to be charged per hour
- It is known that the parking lot has 30 box
- at the end of the day a report should be generated where you should have the car plate, the hour Qtde parked and the amount to be charged for each vehicle. should also be informed the total value of the parking box.
I was able to do it to a certain extent.. but I’m stuck when it comes to displaying the final figures.. how do I calculate the final value of the total?? which formula?
follows 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);
}
}
thanks.. I had managed to find in google.. only now it’s giving error in my string.. I declared right? if I inform more than 2 plates the application hangs
– Fernando Fefu
In fact, it contains a yes error, because the variable i has uninformed value. Vc is creating a table without dimensioning with an unidentified variable. I will fix your program and post the solution in an edition of the code.
– ed1rac
I already put the code redone, no errors.
– ed1rac