-
Notifications
You must be signed in to change notification settings - Fork 1
/
ex07.cpp
42 lines (34 loc) · 889 Bytes
/
ex07.cpp
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
#include <iostream>
#include <string>
struct car
{
std::string name;
int year;
};
int main()
{
int qty = 0;
std::cout << "How many cars do you wish to catalog? ";
(std::cin >> qty).get();
if (qty > 0)
{
car* records = new car[qty];
for (int i = 0; i < qty; i++)
{
std::cout << "Car #" << i + 1 << ":" << std::endl;
std::cout << "Please enter the make: ";
std::getline(std::cin, records[i].name);
std::cout << "Please enter the year made: ";
(std::cin >> records[i].year).get();
}
std::cout << "Here is your collection:" << std::endl;
for (int i = 0; i < qty; i++)
std::cout << records[i].year << '\t' << records[i].name << std::endl;
delete[] records;
}
else
{
std::cout << "Bye!";
}
return 0;
}