-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy 2 oop based c++ code.cpp
More file actions
86 lines (73 loc) · 2.71 KB
/
my 2 oop based c++ code.cpp
File metadata and controls
86 lines (73 loc) · 2.71 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
#include <iostream>
#include <algorithm> // For transform function
#include <cctype> // For toupper function
#include <limits> // For numeric_limits
using namespace std;
class Car {
public:
string name;
string comp_name; // company name
string price;
string max_speed;
string lat_model; // latest model
};
int main() {
string n;
// CIVIC variable for another car
Car c1;
c1.comp_name = "HONDA";
c1.price = "86.6-90 lac";
c1.max_speed = "169 mph";
c1.lat_model = "2024";
// WAGON R variable for another car
Car c2;
c2.comp_name = "SUZUKI";
c2.price = "32,1400 ~(32 lac)";
c2.max_speed = "180 KM/H";
c2.lat_model = "2022";
// CITY variable for another car
Car c3;
c3.comp_name = "HONDA";
c3.price = "Rs. 11.82 lakh to 16.35 lakh";
c3.max_speed = "180 KM/H";
c3.lat_model = "2023";
// COROLLA variable for another car
Car c4;
c4.comp_name = "TOYOTA";
c4.price = "$22,175 - $27,890";
c4.max_speed = "117 mph";
c4.lat_model = "2025";
// gets car name
cout << "Enter car name (IN BLOCK LETTERS OR CAPS): ";
cin.ignore(numeric_limits<streamsize>::max(),"/n"); // Ensure only newline characters are ignored
getline(cin, n);
// Convert user input to uppercase
transform(n.begin(), n.end(), n.begin(), ::toupper);
// Debug statement to check the input after conversion
cout << "Converted input: " << n << endl;
// decides what car's information to show
if (n == "HONDA CIVIC" || n == "CIVIC") {
cout << "PRICE: " << c1.price << endl;
cout << "COMPANY NAME: " << c1.comp_name << endl;
cout << "MAXIMUM SPEED: " << c1.max_speed << endl;
cout << "LATEST MODEL: " << c1.lat_model << endl;
} else if (n == "SUZUKI WAGON R" || n == "WAGON R") {
cout << "PRICE: " << c2.price << endl;
cout << "COMPANY NAME: " << c2.comp_name << endl;
cout << "MAXIMUM SPEED: " << c2.max_speed << endl;
cout << "LATEST MODEL: " << c2.lat_model << endl;
} else if (n == "HONDA CITY" || n == "CITY") {
cout << "PRICE: " << c3.price << endl;
cout << "COMPANY NAME: " << c3.comp_name << endl;
cout << "MAXIMUM SPEED: " << c3.max_speed << endl;
cout << "LATEST MODEL: " << c3.lat_model << endl;
} else if (n == "TOYOTA COROLLA" || n == "COROLLA") {
cout << "PRICE: " << c4.price << endl;
cout << "COMPANY NAME: " << c4.comp_name << endl;
cout << "MAXIMUM SPEED: " << c4.max_speed << endl;
cout << "LATEST MODEL: " << c4.lat_model << endl;
} else {
cout << "Invalid car name" << endl;
}
return 0;
}