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.
I need help with numbers 5, 7, and 8. I could also use a little help with making my output look better with set precision, but that's really not my main concern.
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;