Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 3
- float funCosto (int ar[], size_t j);
- float total(int ar[], size_t t);
- int main (void){
- int hours[SIZE]={0};
- int i,car, x=0;
- printf("Inserire le ore di giacenza:\n");
- for(i=0; i < SIZE; i++){ /*inserisce i valori*/
- scanf ("%d", &hours[i]);
- }
- /*stampa la tabella dei valori*/
- printf ("Car\t Hours\t Charge\n");
- for (car = 0; car < SIZE; car++){
- printf("%d\t %d\t $%.2f\n", car, hours[car], funCosto(hours, car));
- }
- puts("");
- printf("Il totale è: %.2f\n", total(hours, x));
- }
- float funCosto (int ar[], size_t j){ /*prototipo di funzione*/
- float tot; /*calcola le ore in denaro*/
- /*nei vari casi*/
- if (ar[j]<=3){
- tot = 2;
- }
- else if(ar[j]>3 && ar[j]<24){
- tot= (((ar[j]-3)*0.50)+2);
- }
- else if(ar[j]==24){
- tot=10;
- }
- else{
- tot=-1;
- }
- return tot;
- }
- /*calcola il totale*/
- float total(int ar[], size_t t){ /*prototipo di funzione*/
- float sum=0;
- for (t=0; t< SIZE; t++){
- sum += funCosto(ar,t);
- }
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement