Pointer & Loop trouble for final assignment

I am having trouble using pointers for the "Name" and "Address" portion of this code. As well as getting an end for the program at "Are you finished shopping Y/N?" (Way out of program for user, as my Prof says)

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
#include <iostream>
#include <string>
#include <cstdlib>//General Utilities Library for general function purposes

#include "customer.h""

using namespace std;


//Void Function for Week 2
void greeting()
{
	cout << "Welcome to Golf Ballz Inc! \n";
}

int main()
{
	//declaring variables
	string Name, Address;
	char response;

	string *pName, *pAddress;   //declaring the pointers
		
	Customer Client_1;  //Customer Class implemented here
	
	
	pName = &Name;  //Setting the pointers to address
	pAddress = &Address;

	

	//greeting, name and address gathering
	greeting();

	cout << "Please enter your name: \n";

	getline (cin, Name);

	cout << "Welcome " << Client_1.getName() << "!" << endl << endl;    //Print out Welcome message from customer class pointer to get Name

	cout << "Pleae enter your shipping address: \n\n";

	getline(cin, Address);

	Client_1.setName(*pName);   //using customer class with pointers
	Client_1.setAddress(*pAddress);

	//verifying address

	cout << "You entered your shipping address as: " << Client_1.getAddress() << endl << endl;   //Print out address from customer class pointer to get Address



	

	//list of products

	cout << "Here is a list of available products we offer: \n";

	cout << "Mens Golf Ballz \n Come in a variety of hardness and spin control options to rival the Pro's on tour! \n";

	cout << "Womens Golf ballz \n Geared toward our beautiful golf girlz on the course! \n";

	cout << "Kids Golf Ballz \n Offered in a variety of fun colors and designs! \n\n";

	cout << " Each golfer can choose from a variety of colors and designs. \n\n";


	cout << "Would you like to place an order? (Y/N)\n";
	cin >> response;

	//Week 4 I deleted my Week 2 use of Cases and Strings statements with the use of arrays I didn't need them.  The array's replaced the function of each case.
	
	string PRODUCT[3] = { "Men's Golf Ballz", "Women's Golf Ballz", "Kids Golf Ballz" };

	int QUANT[3];

	double PRICE[3] = { 23.00, 20.00, 15.00 };
	//List of products and price in PRODUCT array
	cout << "Product #1 - Men's Golf Ballz are $23.00/dozen" << endl;
	cout << "Product #2 - Women's Golf Ballz are $20.00/dozen" << endl;
	cout << "Product #3 - Kid's Golf Ballz are $15.00/dozen" << endl;

	double total = 0;//inistialize total to zero
	//for loop to allow customer to input amount of each product desired
	for (int counter = 0; counter < 3; counter++)
	{
		cout << "Enter quantity for Product # " << counter + 1 << ": ";
		cin >> QUANT[counter];// customer enters quantities under each product type

		total += QUANT[counter] * PRICE[counter];//equation to give final total of all products
	}
	cout << "Your total bill is : $" << total << endl; //final statement that gives total bill due

	}
	cout << "Are you finished shopping? (Y/N)";
	cin >> response;
			
		system("PAUSE");

	return 0;
}



Customer.h FILE
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
// Header = Function Declaration

#include <iostream>
#include <string>

using namespace std;


#ifndef CUSTOMER_H
#define CUSTOMER_H

class Customer {

public:
	//Default Constructor
	Customer();

	//Overload Constructor
	Customer(string);


private:
	// Variables
	string newName;
	string newAddress;

Customer(string name, string address);

};

#endif 
Last edited on
The first program I ever sold would loop from 1 to 1000 times.
There was no way to quit so I changed it to 0 to 999 times.
Can you imagine doing something 1000 times with no way to quit ?
Your prof is right...

(Way out of program for user, as my Prof says)


You need to loop the entire program while the customer is shopping or provide a menu with a option to quit.

So, in your code, what line are you having trouble with ?
First off 22-28, creating the pointers and using them with the "Customer" class I created to save information then delete it when complete. Also the end of the "main()" line 96-97 using that question to end loop so user can complete order and end interaction. Thanks again for input
Topic archived. No new replies allowed.