Very Simple Program

Hello. I am in an intro to computer science class in school, and I have to make a class based program (with separate implementation files) in order to answer the following question.:

Develop a C++ program that will determine whether a department-store customer has
exceeded the credit limit on a charge account.
For each customer, the following facts are available:

a) Account number (an integer)
b) Balance at the beginning of the month
c) Total of all items charged by this customer this month
d) Total of all credits applied to this customer's account this month
e) Allowed credit limit

The program should use a while statement to input each of these facts, calculate the new balance (= beginning balance + charges – credits)
and determine whether the new balance exceeds the customer’s credit limit. For those customers whose credit limit is exceeded, the program should
display the customer’s account number, credit limit, new balance and the message “Credit Limit Exceeded.”

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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
HEADER
#include <string>
using namespace std ;


class CreditCheck
{
public:
	CreditCheck (double, double, double) ;
	
	void setBeginningBalance ( double ) ;
	double getBeginningBalance () ;
	void setTotalCharge ( double ) ;
	double getTotalCharge () ;
	void setTotalCredit (double ) ;
	double getTotalCredit () ;
	
	double determineNewBalance () ;
	void displayMessage() ;

private:
	double initialBalance ;
	double allTheCharges ;
	double allTheCredit ;

};


CPP FILE
#include <iostream>
#include <iomanip>
#include "header.h"

CreditCheck::CreditCheck ( double b, double c, double ch)
{
	setBeginningBalance (b) ;
	setTotalCredit (c) ;
	setTotalCharge (ch) ;
	
}

void CreditCheck::setBeginningBalance ( double b)
{
	initialBalance = b ;
}

double CreditCheck::getBeginningBalance ()
{
	return initialBalance ;
}

void CreditCheck::setTotalCharge (double ch)
{
	allTheCharges = ch ;
}
double CreditCheck::getTotalCharge ()
{
	return allTheCharges ;
}




void CreditCheck::setTotalCredit (double c)
{
	allTheCredit = c ;
}

double CreditCheck::getTotalCredit ()
{
	return allTheCredit ;
}

double CreditCheck::determineNewBalance ()
{
	return ((initialBalance + allTheCharges) - allTheCredit) ;
}

void CreditCheck::displayMessage()
{
	cout << "Your beginning balance is:" << getBeginningBalance() << endl <<endl ;
	cout << "Your total charges are:" << getTotalCharge() << endl << endl ;
	cout << "Your total credit is:" << getTotalCredit() << endl << endl ;

	cout << "Your new balance is: " << determineNewBalance () << endl<< endl ;
	
}

IMPLEMENTATION FILE
#include "header.h"
#include <iostream>
#include <iomanip>

using namespace std ; 

int main()
{
	CreditCheck checkMyCredit (0, 0, 0) ;
		double credits = 0 ;
		double charges = 0 ;
		double limit = 0 ;
		double balance = 0 ;
		int account ;
		
		
		
	

	cout << endl << "Enter your account number (or enter -1 to quit)        " ;
	cin >> account ;

while (account != -1)
	{
		cout << endl << "Enter initial balance:     " ;
		cin >> balance ;
		cout<< endl << "Enter total charges :      " ;
		cin>>charges ;

		cout << endl << "Enter total credits:     " ;
		cin >> credits ;

		cout << endl << "Enter credit limit:     " ;
		cin >> limit ;

		double balance1 = checkMyCredit.getBeginningBalance () ;
		double charge = checkMyCredit.getTotalCharge () ;
		double credit = checkMyCredit.getTotalCredit () ;
		checkMyCredit.determineNewBalance () ;


		

		if ( balance1 + charge - credit > limit )
		{
			checkMyCredit.displayMessage () ;
			cout << "Credit exceeded" << endl ;
			}
		else
		{
			checkMyCredit.displayMessage () ;
		}
cout<< "Enter account number ( or -1 to quit): " ;
cin >> account ;
	}
return 0 ;
}



The program runs, but it only outputs zeroes and does not do the calculations I intend. I am aware that my error is in all likelihood a very stupid mistake. However, I am new to coding and would appreciate if someone could explain to me WHY the program will not do calculations (By the way, my compiler is Visual C++ 2008)

PS--Thank you in advance
Last edited on
<Bump>
In your main program you're getting user input, but you're never calling any of the set methods of your class, so the user's input never makes it to your class logic.
Topic archived. No new replies allowed.