Classes and member functions program.

My Goal:

Suppose that the Customer class is going to be expanded to keep track of total year-to-date purchases.Declare data fields, accessors and mutators which will keep track of the total number of sales and total sales for each instance of Customer.

Template Code:

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
class Customer
{
public:
   Customer(string name, string address, string city, string state, string zipcode);
   
   void increase_limit(double amount);
   string get_name()  const;
   string get_address() const;
   string get_city()  const;
   string get_state() const;
   double credit_limit;
   /*your work goes here

   */
private:
   string name;
   string address;
   string city;
   string state;
   string zipcode;
   /* and here

   */
  ;
}




What I have so far:

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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include <iostream>
#include <string>
#include <math.h>
#include <cstring>
#include <fstream>

using namespace std;

class Customer
{



public:
	Customer();	//Object constructor
	
	double increase_limit(double amount);  //increases credit limit

	double individual_customer_sales() const;
	
	double credit_limit() const;

	double total_sales() const;
	
	double compare() const;

	void read() const;		//mutator

	void print() const;                // display stuff

	bool add_sales(Customer x) const; //accessor
	

	
private: 

	string name;
	string address;
	string city;
	string state;
	string zipcode;

	double credit_limit;
	double customer_sales[];
	double total_sale;
	double initial_sales;
	double purchase_price;

};

Customer::Customer()
{
	name = " ";
	address= " ";
	city = " ";
	state = " ";
	zipcode = " ";
	int i = 0;
	int x = i++;
	

	double initial sales = 0.0;
	
}
	

double Customer::increase_limit(double amount)
{
	credit_limit = credit_limit + amount;
}

double Customer::credit_limit() const
{
	max_limit = credit_limit

}

double Customer::indiviual_customer_sales();
{
	customer_sales = customer_sales + initial sales
	
}

double Customer::total_sales()
{
	total_sale = customer_sales*x
}

double Customer::compare() const
{
	if (purchase_price > max_limit)
		{
			cout << "CREDIT LIMIT EXCEDDED!!!";
			return 0;
		}
}
			
bool Customer::add_sales(Customer x) const
{
	if (customer_sales > x.customer_sales)
		{
		   return true;
		}
	else 
		{
		   return false;
		}
}

void Customer::read() const
{
	cout >> "Please enter your name: ";
	cin << name;

	cout >> "Please enter your address: ";
	cin << address;

	cout >> "Please enter the city name: ";
	cin << city;

	cout >> "Please enter the state: ";
	cin << state;

	cout >> "Please enter the purchase price. "
	cin << purchase_price;

	cout >> "Please enter number of individual sales: ";
	cin << customer_sales;

	string remainder;          // read remainder of line
	getline(cin, remainder)
}

int main()
{
	Customer y = Customer();
	bool total = true
	while (total)
		{
		  Customer x = customer();
		  x.read();
		  if (add_sales(y))
			{
				y = x;
			}
		  cout << "Here are the total sales!: " << total_sales();
		  cout << "Would you like to see individual sales? (y/n) ";
		  string answer; 
		  getline(cin, answer); 
			if (answer != "y")
			{
				total = false; 
			}
			else (answer = "y")
			{
				cout << customer_sales;
			} 
		}
	y.print();
	return 0;
}




My Question is, how do I accomplish the goal I stated at the top? I am completely stumped and this is due tomorrow. I've chipped away at it over the past few days and can't figure it out.
Last edited on
Is this a question? We're not exactly mind readers. But here are some of your errors:

Line 20 (extra semi-colon):
double credit_limit(); const;
To
double credit_limit() const;

Line 26 (duplicate):
void increase_limit(double amount);
Line 15:
void increase_limit(double amount);

Line 28 (missing function type):
set_address(string address);
To
void set_address(string address);

You have a lot more errors in your program. You need to dwindle it down before you can get any real help from us.
I am about to edit it, help greatly appreciated as this is due tomorrow.
I'm still receiving over 25 errors from your code. Make sure you're attempting to compile it and try to fix as many errors as possible before resubmitting it. If there are errors you can't figure out, paste the error and line number and I'll help you correct your problem.
Topic archived. No new replies allowed.