Hello I'm PSPMAN90 and I'm making an console Program that calculate the electricity bill. When I compiled I get this 8 errors that I tried to fix but I couldn't my self, so I would need a little help, I guess, here I got the .h, .ccp and the AppProgram.cpp(main):
I add the .h and the .cpp because they suppose to run together with the main(AppFacturaElectricidad.cpp), no that them have errors(Factura.h and Factuar.cpp)
#pragma once
// Definition of the class Factura.
class Factura
{
public:
//Constructor
Factura(void);
//Destructor
~Factura(void);
// To assing value to month.
void setMes(int);
// To assing value to lecAnterior.
void setLecAnterior(float);
// To assing value to lecActual.
void setLecActual(float);
// Return the value of the month.
int getMes()const;
// Return the value of the lecAnterior.
float getLecAnterior()const;
// Return the value of lecActual.
float getLecActual()const;
// This determinates the consumption.
float consumoMes();
// This is the first charge.
float cargoPrimero(int val);
// This is the rest of the charge.
float cargoSegundo(int val);
// This is the charge for energy consumed.
float energiaCompra (int val);
// This is the charge for fuel consumed.
float gasCompra (int val);
private:
int
mes; // The month of the year.
float
lecAnterior, // The value of the past reading.
lecActual; // The value of the actual reading.
};
#include "Factura.h"
// DefiniciĆ³n de las funciones de la clase Factura.
Factura::Factura(void)
{
mes = 0;
lecActual = 0.0;
lecAnterior = 0.0;
}
Factura::~Factura(void)
{
}
// To asing value to month.
void Factura::setMes(int val)
{
mes = val;
}
// To asing value to lecAnterior.
void Factura::setLecAnterior(float val)
{
lecAnterior = val;
}
// To asing value to lecActual.
void Factura::setLecActual(float val)
{
lecActual = val;
}
// Return the value of the month. .
int Factura::getMes()const
{
return mes;
}
// Return the value of the lecAnterior.
float Factura::getLecAnterior()const
{
return lecAnterior;
}
// Return the value of the lecActual.
float Factura::getLecActual()const
{
return lecActual;
}
// Return the value of the consumption.
float Factura::consumoMes()
{
return lecActual - lecAnterior;
}
// Return the value of the first charge.
float Factura::cargoPrimero(int val)
{
return val * 0.0435;
}
// Return the value of the second charge.
float Factura::cargoSegundo(int val)
{
return val * 0.0497;
}
// Return the value of the charge consumed.
float Factura::energiaCompra(int val)
{
return val * 0.039429;
}
// Return the value of the fuel consumed.
float Factura::gasCompra(int val)
{
return val * 0.164868;
}
// Nogueras Gantu Joseph 5966 17
// COSC 131 Sec. 304 11/26/2008
// This program will determinate the electricity Bill.
#include <iostream>
#include <iomanip>
#include "Factura.h"
usingnamespace std;
int main()
{
int cant; // To enter temporal quantities.
float costos ; // To enter temporal costs.
Factura cargos; // Object cargos is created.
cout << fixed << setprecision(2);
cout << "\n\n\n\n\t\aHello! This program will calculate your electricity bill,"
<< " please feel free of using it.\n\n\n\n";
system("pause");
system("cls");
cout << "\n\n\n\tEnter the desired month: ";
cin >> cant;
cargos.setMes(cant);
cout << "\n\n\tEnter the desired cost of the past reading: ";
cin >> costos;
cargos.setLecAnterior(costos);
cout << "\n\n\tEnter the desired cost of the actual reading: ";
cin >> costos;
cargos.setLecActual(costos);
if(consumoMes() >= 425)
{
cargo1 = cargos.cargoPrimero(425),
cargo2 = cargos.cargoSegundo(consumoMes() - 425);
}
if(consumoMes() < 425)
{
cargo1 = cargos.cargoPrimero(consumoMes()),
cargo2 = 0.0;
}
system("pause");
system("cls");
cout << "\n\n\n\n\n\tThe past reading is: " << cargos.getLecAnterior();
cout << "\n\n\n\n\n\tThe actual reading is " << cargos.getLecActual();
cout << "\n\n\n\n\n\tThe month consumption is " << cargos.consumoMes();
system("pause");
system("cls");
cout << "\n\n\n\n\t\aMuchas gracias por usar nuestro programa.""\n\n\tEsperamos que le haya ayudado con sus compra.""\n\n\tLo puede volver a usar cuando lo desee.\n\n\n";
system("pause");
return 0;
}
So if any experienced, advance programer outhere would like to help me out on this I will be really graceful. Just need to fix those 8 errors and that's it.
consumoMes() is used as global function but it is a member function, so it should be called like this: cargos.consumoMes() (lines 42,45,48,50) cargo1 and cargo2 are not declared: add float cargo1, cargo2; before line 42
If you read carefully the error messages, you will see that they explain how to fix the problems:
Errors 2,3,6,7 say that cargo1 and cargo2 weren't declared so you need to declare them
Other errors say that consumoMes() wasn't found so yo need to see if and in which scope you declared it