-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassign5.9.7.cpp
More file actions
41 lines (28 loc) · 765 Bytes
/
assign5.9.7.cpp
File metadata and controls
41 lines (28 loc) · 765 Bytes
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
#include <iostream>
#include <string>
struct Car
{
std::string make;
int year;
};
int main()
{
int carNum;
std::cout << "How many cars do you wish to catalog? ";
(std::cin >> carNum).get();
Car* carPtr = new Car[carNum];
for (int i = 0; i < carNum; i++)
{
std::cout << "Car #" << i + 1 << ":" <<std::endl;
std::cout << "Please enter the make: ";
std::getline(std::cin, (carPtr + i)->make);
std::cout << "Please enter the year made: ";
(std::cin >> (carPtr + i)->year).get();
}
std::cout << "Here is your collection: " << std::endl;
for (int j = 0; j < carNum; j++)
{
std::cout << carPtr[j].year << " " << carPtr[j].make << std::endl;
}
return 0;
}