Hi there, could someone please help me debug this code. I need it to perform the following tasks
1. Ask the user for the number of cars he or she owns.
2. Create a class to represent a car, and then declare an array of cars.
3. Ask the user what the color, weight, and model is for each car he or she owns. Store this in the array.
4. Once the user has entered all data, calculate the combined weight of the cars.
//car.cpp
//program to get information about a persons cars.
#include<stdafx.h>
#include<iostream>
#include<string.h>
using namespace std;
int number;
float total = 0;
class car
{
private:
char colour[10];
float weight;
char model[50];
public:
void setdata(char c[], float w, char m[])
{
strcpy_s(colour,c);
weight = w;
strcpy_s(model, m);
}
void showdata()
{
for(int i = 0; i<number; i++)
{
total += fleet[i].weight;
}
cout << "\n Your " << number << " cars weigh a total of " << total << " pounds." <<endl;
}
};
void main()
{
cout << "\nPlease enter the number of cars you own.";
cin >> number;
new car fleet[number];
char col[10];
float wgt;
char mod[50];
float total;
for(int i = 0; i<number; i++)
{
cout << "\n Please enter the colour of car number" << i+1 << ":"<<endl;
cin >> col;
cout << "\n Please enter the weight of car number"<< i+1 <<":"<<endl;
cin >> wgt;
cout << "\n Please enter the model of car number" << i+1 << ":"<<endl;
cin >> mod;
fleet[i].setdata(col,wgt,mod);
fleet[i].showdata();
}
}//end main