Hello all I need a little help finishing my assignment.

I am given a text file that contains information about vehicles in an auto dealership.
The vehicle records consist of the following fields:
VIN, Make, Model, Year, Color, Date of purchase, Cost, Date of Sale, Sale Price and Revenue.

The text file contains one vehicle record per each line. I need to write a program to do the following:

  1. Reads the input file one line at a time and stores the appropriate data into the structure data fields in your program.
  2. Computes and sets revenue made on each vehicle if it is sold.
  3. Displays every vehicle record on a separate line.
  4. Computes and displays number of vehicles with a year newer than 2000.
  5. Computes and displays total revenue made on all sold vehicles.
  6. Computes and displays number of vehicles costing less than $5000.
  7. Computes and displays number of vehicles with a black color.
  8. Computes and displays number of vehicles of Toyota make and red color.

It does numbers 1, 2, and 3 fine, but it messes up on the rest. I also need help formatting it using the set width so my output looks a lot my organized.

This is a copy of my input file:

02345678ABCDEF	TOYOTA	Camry	2007	Black	8 24 2009	5350	11 17 2010 7100
12345678ABCDEF	TOYOTA	Corolla	2005	Silver	6 11 2006	2550	3  1  2008 2800
22345678ABCDEF	NISSAN	Altima	2000	Red	1 6  2001	4300	12 9  2002 5200
32345678ABCDEF	NISSAN	Maxima	2010	White	3 12 2003	7500	1  11 2005 4000
42345678ABCDEF	NISSAN	Cube	2009	Red	5 16 2008	6100	3  1  2011 6000
52345678ABCDEF	HONDA	CR-X	1985	Red	8 11 1990	2330	1  1  1990 3300
62345678ABCDEF	HONDA	Civic	1999	Blue	5 15 2001	4520	3  6  2003 5022
72345678ABCDEF	HONDA	Accord	2001	Gold	9 12 2010	1180	11 19 2010 3300
82345678ABCDEF	FORD	Mustang	1989	Red	4 18 2000	4000	5  1  2001 4700
92345678ABCDEF	FORD	F150	2005	Black	7 16 2006	10000	9  28 2007 11300

This is a copy of my code:

# include <cmath>
# include <iostream>
# include <iomanip>
# include <cstring>
# include <cctype>
# include <fstream>
# include <string> 

using namespace 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;
float sale;
float 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; 
 cout << "Total Revenue = " << sum << endl; 

if (mycar.year > 2000) 
	 {++cnt2000; 
 cout << "Year greater than 2000 = " << cnt2000 << endl; } 

 if (mycar.cost < 5000) 
	 {++cnt5000; 
 cout << "Cost less than 5000 = " << cnt5000 << endl; }

 if (mycar.color == "black")
	{ ++cntcolor; 
 cout << "Blacks = " << cntcolor << endl; } 

 if (mycar.make == "toyota" && mycar.color == "red") 
	 {++cntcoma; 
 cout << "Toyota and Red = " << cntcoma << endl; } 
	  

	system ("pause"); 
	return 0; 

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.