8 erros that are need to be fix

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)


Factura.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#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.
};



Factura.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#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;
}


Here where I get those 8 errors in main.

AppFacturaElectricidad.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// 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"

using namespace 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.

Thanks

Joey

Last edited on
Alright! A chance to try out my new PSYCHIC POWERS to figure out what these 8 errors were!
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

To sum up, from line 42 to 52 the code should be:
1
2
3
4
5
6
7
8
9
10
11
float cargo1, cargo2;
if(cargos.consumoMes() >= 425)
{
     cargo1 = cargos.cargoPrimero(425),
     cargo2 = cargos.cargoSegundo(cargos.consumoMes() - 425);
}
else
{
     cargo1 = cargos.cargoPrimero(cargos.consumoMes()),
     cargo2 = 0.0;
}

Last edited on
ohhh lol I forgot to post them :D, I'm sorry -_-'!

Good one, tough...

Here are those 8 errors to be fixed:

1
2
3
4
5
6
7
8
Error	1	error C3861: 'consumoMes': identifier not found	z:\2008 vs projects\josephfacturaelectricidad\josephfacturaelectricidad\appfacturaelecticidad.cpp	42
Error	2	error C2065: 'cargo1' : undeclared identifier	z:\2008 vs projects\josephfacturaelectricidad\josephfacturaelectricidad\appfacturaelecticidad.cpp	44
Error	3	error C2065: 'cargo2' : undeclared identifier	z:\2008 vs projects\josephfacturaelectricidad\josephfacturaelectricidad\appfacturaelecticidad.cpp	45
Error	4	error C3861: 'consumoMes': identifier not found	z:\2008 vs projects\josephfacturaelectricidad\josephfacturaelectricidad\appfacturaelecticidad.cpp	45
Error	5	error C3861: 'consumoMes': identifier not found	z:\2008 vs projects\josephfacturaelectricidad\josephfacturaelectricidad\appfacturaelecticidad.cpp	48
Error	6	error C2065: 'cargo1' : undeclared identifier	z:\2008 vs projects\josephfacturaelectricidad\josephfacturaelectricidad\appfacturaelecticidad.cpp	50
Error	7	error C2065: 'cargo2' : undeclared identifier	z:\2008 vs projects\josephfacturaelectricidad\josephfacturaelectricidad\appfacturaelecticidad.cpp	51
Error	8	error C3861: 'consumoMes': identifier not found	z:\2008 vs projects\josephfacturaelectricidad\josephfacturaelectricidad\appfacturaelecticidad.cpp	50

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
Last edited on
consumoMes() is a non-static member of Factura, so you need a instance of it to call it.
Thanks everyone for helping me to fix those errors.
I'll be around to learn some more!
PSPMAN90
Topic archived. No new replies allowed.