Please help me figure out this problem. I enter data for 3 laptops and loop prints data of the last laptop only for 3 times.
#include <iostream> #include <string> using namespace std; class laptop { private: string brand; string model; int serial; string color; float price; float processor_Speed; int ram; float screen_Size; public: void display() { cout<<"Brand: "<<brand<<endl; cout<<"Model: "<<model<<endl; cout<<"Serial No. "<<serial<<endl; cout<<"Color: "<<color<<endl; cout<<"Price: "<<price<<endl; cout<<"Processor Speed: "<<processor_Speed<<endl; cout<<"RAM :"<<ram<<endl; cout<<"Screen Size: "<<screen_Size<<endl; cout<<"-------------------"<<endl; } laptop(string b, string m, int s, string c, float p, float ps,int r, float sz) { brand = b; model = m; serial = s; color = c; price = p; processor_Speed = ps; ram = r; screen_Size = sz; } }; int main() { string brand; string model; int serial; string color; float price; float processor_Speed; int ram; float screen_Size; for (int i = 0; i<3; i++) { cout << "Laptop model :" << i + 1 << endl << endl; cout << "Brand name (string):"; cin >> brand; cout << "Modal name (string):"; cin >> model; cout << "Serial name (int):"; cin >> serial; cout << "color name (string):"; cin >> color; cout << "Price (int):"; cin >> price; cout << "processor speed (float):"; cin >> processor_Speed; cout << "RAM (int):"; cin >> ram; cout << "Screen size (float):"; cin >> screen_Size; cout << endl << endl; } cout << "____________________________________" << endl; for (int i = 0; i<3; i++) { cout << "Laptop Model :" << i + 1 << endl << endl; laptop details(brand, model, serial, color, price, processor_Speed, ram, screen_Size); details.display(); // print.upgrade_RAM(); cout << endl << endl << endl; cout << "_