-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
89 lines (45 loc) · 1.33 KB
/
Source.cpp
File metadata and controls
89 lines (45 loc) · 1.33 KB
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
#include "Book.h"
using namespace std;
void comparePrices(const Book& b1, const Book& b2) {
if (b1.cost > b2.cost) {
cout << "Book1 is more expensive than book2.\n";
}
else if (b1.cost < b2.cost) {
cout << "Book2 is more expensive\n";
}
else if (b1.cost == b2.cost)
cout << "The Prices are the same\n";
}
int main() {
//const Book book1((string&)"The Great Med", 999.99);
string name = "The Great Med";
const Book book1(name, 999.99);
Book book2("The catcher in the bar", 12.99);
Book book3("To kill a MockingMed", 97.67);
book1.printBook();
cout << endl;
book2.printBook();
cout << endl;
book3.printBook();
cout << endl;
cout << "They are " << Book::getCount() << "Books \n\n";
comparePrices(book1, book2);
if (book1 > book2) {
cout << "Book 1 is more expensive.\n";
}
else
cout << "Book 2 is more expensive.\n";
if (book2 > 2000) {
cout << "Book 2 is more than 2000$\n";
}
else
cout << "Book 2 is less than 2000\n";
double avg{};
avg = (book1 + book2) / 2.0;
cout << "The average price is $" << avg << endl;
cout << "==================";
cout << "Printing Books using << operator.\n";
cout << "Book1:\n" << book1 << "Book2:\n" << book2
<< "Book3:\n" << book3 << endl;
return 0;
}