Professional Documents
Culture Documents
Final File - Incorporated Deliverable
Final File - Incorporated Deliverable
INFORMATICS FACULTY
struct Car {
string make;
string model;
int year;
int price;
string engineSize;
string mileage;
string color;
string transmission;
string fuelType;
string contact;
};
struct Seller {
string name;
string phone;
Car cars[10]; // a fixed-size array of cars owned by the
seller
int numCars; // a variable to store the number of cars in the
array
};
struct Buyer {
string name;
string phone;
};
<<"|-------|---------------|---------------|------|---------|\
n";
int index =1; // a counter for the index of each car
for (int i =0; i < numSellers; i++) { // loop through all the
sellers
for (int j =0; j < sellers[i].numCars; j++) { // loop
through all the cars of each seller
cout<<"| "<<index<<" "
<<"| "<<sellers[i].cars[j].make<<" "
<<"|"<<sellers[i].cars[j].model<<" "
<<"| "<<sellers[i].cars[j].year<<""
<<"|$"<<sellers[i].cars[j].price<<"|\n";
index++; // increment the index
}
}
cout<<"\
n|-------|---------------|---------------|------|---------|\n";
}
for (int i =0; i < numSellers; i++) { // loop through all the
sellers
if (sellers[i].name == name && sellers[i].phone == phone) {
// check if the seller matches the input
foundSeller = true; // set the flag to true
sellerIndex = i; // store the index of the seller
break; // exit the loop
}
}
if (foundSeller) {
cout<<"Enter the index of the car you want to update: ";
cin>>carIndex;
cin.ignore();
getline(cin,sellers[sellerIndex].cars[carIndex].fuelType); //
read new fuel type from input and update the car
cout<<"You have successfully updated your car."<<endl; //
display a confirmation message
} else {
cout<<"Invalid car index."<<endl; // display an error
message
}
} else {
cout<<"Sorry, you are not registered as a seller."<<endl;
}
}
if (foundSeller) {
cout<<"Enter the index of the car you want to remove: ";
cin>>carIndex;
cin.ignore();