#include <stdio.h>
int main( ) {
struct pessoas {
int codTC; //codigo do consumidor para falar se é 1-Residencial 2-Comercial 3-Industrial
int num; //numero do consumidor (vou colocar o numero referente ao cod para nao confundir)
float kwh; //Quilowatt-hora
} ;
struct pessoas consumidor[ 16 ] ;
float total, totalT, consumo1, consumo2, media;
int i = 0 ;
printf ( "Exercício desenvolvido considerando a tarifa do CIP - Contribuição Municipal\n " ) ; do {
printf ( "\n Digite o numero do consumidor: " ) ; scanf ( "%i" , & consumidor
[ i
] .
num ) ; if ( consumidor[ i] .num == 0 ) {
break ;
}
printf ( "\n Tipo de consumidor, digite:\n 1 - Residencial\n 2 - Comercial\n 3 - Industrial: " ) ; scanf ( "%i" , & consumidor
[ i
] .
codTC ) ; printf ( "\n Digite a quantidade de kWh consumidos durante o mes: " ) ; scanf ( "%f" , & consumidor
[ i
] .
kwh ) ; if ( consumidor[ i] .codTC == 1 ) {
total = consumidor[ i] .kwh * 0.3 ;
consumo1 = consumidor[ i] .kwh ; //isto não faz sentido mas deixei
} else if ( consumidor[ i] .codTC == 2 ) {
total = consumidor[ i] .kwh * 0.5 ;
consumo2 = consumidor[ i] .kwh ; //isto não faz sentido mas deixei
} else if ( consumidor[ i] .codTC == 3 ) {
total = consumidor[ i] .kwh * 0.7 ;
}
totalT = total + 5.17 ;
media = consumo1 + consumo2 / 2 ; //isto não faz sentido mas deixei
printf ( "\n O total de consumo e %.2f\n " , total
) ; printf ( "\n O custo total e %.2f\n " , totalT
) ; printf ( "\n A media de consumo dos consumidores 1 e 2 e %.2f\n " , media
) ; i++;
} while ( i == 16 ) ;
return ( 0 ) ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CmludCBtYWluKCkgewogICAgc3RydWN0IHBlc3NvYXMgewogICAgICAgIGludCBjb2RUQzsgLy9jb2RpZ28gZG8gY29uc3VtaWRvciBwYXJhIGZhbGFyIHNlIMOpIDEtUmVzaWRlbmNpYWwgMi1Db21lcmNpYWwgMy1JbmR1c3RyaWFsCiAgICAg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