0
I have tried several times, but the compiler does not understand the references made in the header of the function void CalculaValorparaPagar(float ValorPago[MAX], float Quant_Kwh[MAX],float Preco[MAX], int bandeira[MAX], int tipo[MAX])
and in main CalculaValorparaPagar(&ValorPago[MAX],Quant_Kwh,Preco,bandeira,tipo/i/);
and gives the following error:
[Error] cannot Convert 'float' to 'float' for argument '1' to 'void Calculatedfloat(float, float, float, int, int)
How should I proceed?
#include <stdio.h>
//#include "headerfiledoconsumo.h"
#define MAX 2
int x;
float Imposto[MAX], Taxa_ilum [MAX];
float Taxa_Band_Tar [MAX];
float Quant_Kwh [MAX];
int tipo [MAX];
float ValorPago[MAX];
float Preco[MAX];
int bandeira[MAX];
//void CalculaValorparaPagar();
//void fazperguntas();
//void imprimevalorpagar();
void fazperguntas(/*float Quant_Kwh[MAX],float Preco[MAX],int tipo[MAX],int bandeira[MAX]*/){
for (int i= 0; i<MAX; i++){
//printf("Informe seu nome:\n");
//scanf("%s", &nome[i]);
printf("Informe seu consumo em KW: \n");
scanf("%f", &Quant_Kwh[i]);
getchar();
printf("Digite o preco do Khw: \n");
scanf("%f", &Preco[i]);
getchar();
printf("Informe o tipo de consumidor que voce eh: 1(residencial), 2(comercial), 3(Industrial)\n");
scanf("%d", &tipo[i]);
getchar();
printf("Informe a bandeira tarifaria: Verde(1), Amarela(2), Vermelha(3)\n");
scanf("%d", &bandeira[i]);
getchar();
}
}
void CalculaValorparaPagar(float *ValorPago[MAX], float Quant_Kwh[MAX],float Preco[MAX], int bandeira[MAX], int tipo[MAX]){
//int i = 10;
for(int i=0; i<MAX;i++){
if (bandeira[i] == 1){
Taxa_Band_Tar[i] = 0;
}
if(bandeira[i] == 2 || Quant_Kwh[i] > 100){
x = (Quant_Kwh[i]/100);
Taxa_Band_Tar[i] = x*3.5;
}
if(bandeira[i] == 3 || Quant_Kwh [i] >100){
x = (Quant_Kwh[i]/100);
Taxa_Band_Tar[i] = x*10.5;
}
if (tipo[i] == 1){
Taxa_ilum[i] = 23.45;
}
if(tipo[i] == 2){
Taxa_ilum[i] = 29.23;
}
if(tipo[i] == 3){
Taxa_ilum[i] = 37.06;
}
Imposto[i] = 0.04*Quant_Kwh[i] + 0.02*Taxa_ilum[i];
*ValorPago[i] = Quant_Kwh[i]*Preco[i] + Taxa_ilum[i] + Imposto[i] + Taxa_Band_Tar[i];
}
}
void imprimevalorpagar(){
for(int i = 0; i<MAX; i++){
printf("Consumidor %d Valor a pagar: %f\n", i,ValorPago[i]);
}
}
int main() {
fazperguntas();
CalculaValorparaPagar(&ValorPago[MAX],Quant_Kwh,Preco,bandeira,tipo/*i*/);
imprimevalorpagar();
}
The first thing you need to decide is whether to put the variables as global or local, doing both at the same time doesn’t work. It’s more complicated to do everything local, but it’s right, global it’s gambit.
– Maniero
Thank you very much, I’ll try here!
– Vinicius