Hello all, I had to made a code to read from an input file using structures. The input file was information relating to a car dealership. I didn't post the input file, but I can if you need me to. I had to calculate the total revenue, the cars that have years greater than 2000, the cars that have prices under 5000, the cars that were black, and the cars that were toyotas and red. I am having trouble with the total revenue, the cars that are black, and the cars that are toyotas and red, other than that my program works fine. Can you help me please?
Code:# include<cmath> # include<iostream> # include<iomanip> # include<cstring> # include<cctype> # include<fstream> # include<string> usingnamespace std; int main() {ifstream fin; fin.open("fin.txt"); int cnt2000 = 0; int cnt5000 = 0; int cntcolor = 0; int cntcoma = 0; int sum = 0; struct car { string id; string make; string model; int year; string color; int purchase_month; int purchase_day; int purchase_year; float cost; int sold_month; int sold_day; int sold_year; int sale; int revenue; }mycar; cout << "ID " << "Make " << "Model " << "Year " << "Color " << "Purchased " << "Cost " << "Sold " << "Sale " << "Revenue " << endl; cout << "************************************************************************" << endl; while (fin) {fin >> mycar.id >> mycar.make >> mycar.model >> mycar.year >> mycar.color >> mycar.purchase_month >> mycar.purchase_day; fin >> mycar.purchase_year >> mycar.cost >> mycar.sold_month >> mycar.sold_day >> mycar.sold_year >> mycar.sale; mycar.revenue = mycar.sale - mycar.cost; cout << mycar.id << " " << mycar.make << " " << mycar.model << " " << mycar.year << " " << mycar.color << " "; cout << mycar.purchase_month << "/" << mycar.purchase_day << "/" << mycar.purchase_year << " " << mycar.cost << " "; cout << mycar.sold_month << "/" << mycar.sold_day << "/" << mycar.sold_year << " " << mycar.sale << " " << mycar.revenue << endl; cout << endl; sum = ++mycar.revenue; if (mycar.year > 2000) {++cnt2000; } if (mycar.cost < 5000) {++cnt5000; } if (mycar.color == "black") { ++cntcolor; } if (mycar.make == "toyota" && mycar.color == "red") {++cntcoma; } }; cout << "Total Revenue = " << sum << endl; cout << "Year greater than 2000 = " << cnt2000 << endl; cout << "Cost less than 5000 = " << cnt5000 << endl; cout << "Blacks = " << cntcolor << endl; cout << "Toyota and Red = " << cntcoma << endl; system ("pause"); return 0; }