More Used Car Dealership Help

I posted about this assignment last night, and am now almost completed. I just have one more thing that i need to figure out. On option 6 of my main menu, I'm supposed to be able to upload some .txt files that were given to me as part of the assignment (I'll include them below). I don't just need to output the next, but I actually need to have the text added into my car inventory in the appropriate parts.
I'm not allowed to touch the class header or the functions. I'm working exclusively within main(), and focused on the if(option == 6) portion.

Here is my code so far, including the class header and functions (which are stored in different files in my compiler).

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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
  //WARNING: It is expressly forbidden to modify any part of this document, including its name
#pragma once
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

class Car
{
private:
	string name;
	string color;
	double price;

public:
	//---------------------------------------------------------------------------------------
	/*
	* Constructor/Destructor
	*
	* Handles creation and deletion of Car objects.
	*
	* Parameter: name_in
	*		The name of a new car
	* Parameter: color_in
	*		The color of a new car
	* Parameter: price_in
	*		The price of a new car
	*/
	Car(string name_in, string color_in, double price_in);
	virtual ~Car();
	//---------------------------------------------------------------------------------------
	/*
	* getName
	*
	* Returns the name of the car.
	*
	* Return:
	*		The name of the car
	*/
	string getName();
	/*
	* getColor
	*
	* Returns the color of the car.
	*
	* Return:
	*		The color of the car
	*/
	string getColor();
	/*
	* getPrice
	*
	* Returns the price of the car.
	*
	* Return:
	*		The price of the car
	*/
	double getPrice();
	//---------------------------------------------------------------------------------------
	/*
	* paint
	*
	* Paints the car a new color and increases the price by $1,000.
	*
	* Parameter: new_color
	*		The color of paint to be used on the car
	*/
	void paint(string new_color);
	//---------------------------------------------------------------------------------------
	/*
	* toString
	*
	* Returns a single string containing useful information about the car.
	*
	* Return:
	*		A data string about this car
	*/
	string toString();
	//---------------------------------------------------------------------------------------
};


//WARNING: It is expressly forbidden to modify any part of this document, including its name
#include "car.h"
using namespace std;

//---------------------------------------------------------------------------------------
Car::Car(string name_in, string color_in, double price_in)
{
	name = name_in;
	color = color_in;
	price = price_in;
}
Car::~Car() {}
//---------------------------------------------------------------------------------------
string Car::getName()
{
	return name;
}
string Car::getColor()
{
	return color;
}
double Car::getPrice()
{
	return price;
}
//---------------------------------------------------------------------------------------
void Car::paint(string new_color)
{
	color = new_color;
	price += 1000;
}
//---------------------------------------------------------------------------------------
string Car::toString()
{
	stringstream ss;
	ss << "Name: " << name << endl;
	ss << "Color: " << color << endl;
	ss << "Price: $" << price << endl;
	return ss.str();
}
//---------------------------------------------------------------------------------------


#include <iostream>
#include "car.h"
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>

using namespace std;

int main()
{
	int option;
	string name;
	string color;
	double price = 0;
	double balance = 10000;
	vector <Car> cars;

	do
	{
		cout << "Please select an option:" << endl;
		cout << "1 - Show current inventory." << endl;
		cout << "2 - Show current balance." << endl;
		cout << "3 - Buy a car." << endl;
		cout << "4 - Sell a car." << endl;
		cout << "5 - Paint a car." << endl;
		cout << "6 - Load file." << endl;
		cout << "7 - Save file." << endl;
		cout << "8 - Quit program." << endl;
		cout << "\n";

		cin >> option;

		if (option == 1)
		{
			for (int i = 0; i < cars.size(); i++)
			{
				cout << cars[i].toString();
			}
		}
		if (option == 2)
		{
			cout << "$" << balance << endl;
		}
		if (option == 3)
		{
			cout << "Please enter the name, color, and price of the car you would like to buy." << endl;
			cin >> name;
			cin >> color;
			cin >> price;
			Car newcar(name, color, price);

			if (price <= balance)
			{
				cars.push_back(newcar);
				cout << "Car has been purchased." << endl;
				balance = balance - price;
			}
			else
			{
				cout << "You cannot afford that car." << endl;
				option = 0;
			}
		}
		if (option == 4)
		{
			cout << "Please enter the name of the car you want to sell." << endl;
			cin >> name;
			bool found = true;

			for (int j = 0; j < cars.size(); j++)
			{
				if (cars[j].getName() == name)
				{
					found = false;
					price = cars[j].getPrice();
					cars.erase(cars.begin() + j);
					cout << "You have sold the " << name << endl;
					balance = balance + price;
				}
				else
				{
					cout << "You don't own that car." << endl;
				}
			}
		}
		if (option == 5)
		{
			cout << "Please enter the name of the car you want to paint." << endl;
			cin >> name;
			bool found = true;

			for (int j = 0; j < cars.size(); j++)
			{
				if (cars[j].getName() == name)
				{
					found = false;
					cout << "What color do you want to paint the " << name << "?" << endl;
					cin >> color;
					cars[j].paint(color);
					cout << "You have painted the " << name << " " << color << "." << endl;
				}
				else
				{
					cout << "You don't own that car." << endl;
				}
			}
		}
		if (option == 6)
		{
			string chooseFile;
		}
		if (option == 7)
		{
			for (int i = 0; i < cars.size(); i++)
			{
				ofstream fout;
				fout.open("Lab 8.txt");
				fout << cars[i].toString() << endl;
				fout << "$" << balance << endl;
			}
		}
		if (option == 8)
		{
			exit(0);
		}
		if (option < 0 || option > 8)
		{
			cout << "Please enter a number from 1-8." << endl;
		}

		cout << "\n";
	} while (option < 8 || option > 8);
}


Here is the content of the text files I'm supposed to be able to upload.
1
2
3
4
529.23
Jalopy Blue 3402.99
Rustbucket Brown 44.99
Lemon Yellow 4226.99

1
2
3
4
5
6
7
8
9
59715.43
Navy White 6972.15
Kidney Red 3971.15
Refried Brown 9999.99
Garbanzo White 975.21
Black Black 7946.85
Edamame Green 555.55
Lima White 5873.15
Pinto Brown 12368.99
Hi,

If you have more questions about the same subject, can we ask you to just keep the original Topic going :+). Duplicate Topics can become a time waster for those who reply, the same things are said by different respondents in different topics. If one does a new post in a topic, it will be bumped to the top of the list.

Cheers :+)
Done. Thanks for the tip, I'm new here. Is there a way to delete this thread?
Hi,

One can delete their own posts, then I can delete mine :+) This will be fine as long as no one else posts.
Topic archived. No new replies allowed.