problems in class

The questions are:
1. Define the class with its methods.
a. The default constructor.
b. The constructor accepts three parameters: brand, price and CC and
assign the parameters to the respective members or variables.
c. Two assessors method:
i. getBrand() which will return brand, and
ii. getPrice() which will be return price.
d. The roadTax() function that identify the road tax. The road tax
amount is based on the following Table 1.
CC Road Tax
($)
CC<=1000 100
1000<CC<=2000 150
CC>2000 200
e. print() function that prints all one car information.

2. ProcessOutput function is a function that has the following function
prototype.This function must accept the cars array as the parameter.
void processOutput(Car *);
This function performs the following tasks in sequence.
1) Print all the six cars information.
2) Calculate and print the total road tax for all six cars.
3) Calculate and print the total price for all six cars.
4) Find the cheapest car among the six cars.
5) Find the most expensive car among the six cars.
6) Print the cheapest and the most expensive car brand and price.

3. The main() function perform the following tasks:
1) Declare an array of type Car called cars class which contain 6 data of Car
objects.
2) Initialize all the six car objects in the array with values read from a keyboard.
3) Call processOutput function with cars as the argument.


Here is my coding :

//Car.cpp
//Lab 1 , exercise 10, number 4

#include <iostream>
#include <cstring>
#include <conio>

class Car
{
public:
Car();
Car (string, double, int);
double getBrand();
double getPrice();
int calculateRoadTax();
void print();

private:
string brand;
double price;
int CC;
int roadTax;
}

Car::Car()
{}

Car::setCar(string b, double p, int c)
{
brand = b;
price = p;
CC = c;
}

string Car::getbrand()
{ return brand; }

double Car::getprice()
{ return price; }

double Car::getCC()
{ return CC; }

void roadTax(int CC)
{
if (CC <= 100)
{
roadTax = 100;
}
if else (1000 < CC <= 2000)
{
roadTax = 150;
}
else
roadTax = 200;
}

void print()
{
cout << "The brand of the car is : " << getbrand() << endl;
cout << "The price of the car is : RM" << getprice() << endl;
cout << "The CC of the car is : " << getCC() << endl;
cout << "The road tax of the car is : " << roadTax(int, double) << endl;
}

void processOutput(Car *)
{
for (int i=0; i<6; i++)
{
cout << "Printing car information for car : " << i << endl;
cout << print() << endl;
}

totalroadTax += roadTax;
cout << "Total road tax for 6 cars = " << totalroadTax << endl;

totalprice += price;
cout << "Total price for 6 cars = " << totalprice << endl;

if (price = low)
{
cout << "The cheapest car." << endl;
}
else (price = high)
cout << "The most expensive car." << endl;

cout << "The cheapest car : \n" << getbrand() << "\n" << getprice() << endl;
cout << "The most expensive car : \n" << getbrand() << "\n" << getprice()
<< endl;

}

int main()
{
const int Car = 6;
string brand[Car] = {"Toyota", "Mazda", "Honda", "BMW", "Ferrari", "Porche"};
double price[Car] = {80000.00, 98000.00, 66000.00, 74000.00, 200000.00,
350000.00};
int CC[Car] = {1500, 1500, 1500, 2000, 2500};

cout << processOutput(int ) << endl;

getch();
return 0;
}

My problems :
1. it's says that Car can't be defined and constructor can't have return type.
2. Because of undefined class Car all the function can't be identified.

So, please help me with this problem.
First line in main(). 'Car' already exists as a type, so you can't use it to declare a variable.
1. Class declaration should end with ;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <iostream>
#include <conio.h>
using namespace std;//added
using std::cout;//added

class Car
{
public:
Car();
Car (string, double, int);
string getBrand();
double getPrice();
double calculateRoadTax();
double Car::getCC();
int GetRoadTax()
{
	return roadTax;
}
void print();

void roadTaxCalculated();//added to class

private:
string brand;
double price;
int CC;
int roadTax;
}; //Added ; class declaration must end with 

Car::Car()
{}

Car::Car(string b, double p, int c)//removed set. you are implementing constructor
{
brand = b;
price = p;
CC = c;
}

string Car::getBrand()
{ return brand; }

double Car::getPrice()
{ return price; }

double Car::getCC()
{ return CC; }

double Car::calculateRoadTax() //Added Car:: -  function is now member of class
{
if (CC <= 100)
{
roadTax = 100;
}
else if(CC > 1000 && CC <=2000) //Changed - this is correct sintax
{
roadTax = 150;
}
else
roadTax = 200;
return roadTax;
}

void Car::print()//Added Carr::
{
	cout << "The brand of the car is : " << getBrand().c_str() << endl;
	cout << "The price of the car is : RM " << getPrice() << endl;
	cout << "The CC of the car is : " << getCC() << endl;
	cout << "The road tax of the car is : " << calculateRoadTax() << endl;
}

void processOutput(Car ** lCar,int numCars)//added lCar - you must have variable name too in this case
{
int totalroadTax = 0;//added local variable
double totalprice = 0;//added local variable
for (int i=0; i<numCars; i++)
{
cout << "Printing car information for car : " << i+1 << endl;
lCar[i]->print();//Added ICar-> - you are accessing print() function of lcar object

totalroadTax += lCar[i]->GetRoadTax();//Transferred in loop
totalprice += lCar[i]->getPrice();//Transferred in loop
}

cout << "Total road tax for " << numCars << " cars = " << totalroadTax << endl;


cout << "Total price for " << numCars << " cars = " << totalprice << endl;



}

int main()
{
const int numOfCars = 6;
Car** myCars = new Car*[numOfCars];//Allocating memory for numOfCars pointers to Car

myCars[0] = new Car("Toyota",80000.00,1500);
myCars[1] = new Car("Mazda",98000.00,1500);
myCars[2] = new Car("Honda",66000.00,1500);
myCars[3] = new Car( "BMW",74000.00,2000);
myCars[4] = new Car( "BMW",200000.00,2500);
myCars[5] = new Car("Porche",250000,3000);


processOutput(myCars ,numOfCars );

_getch();
for(int i=0;i<numOfCars ;i++)
delete myCars[i];//Freing memory
delete [] myCars;
return 0;
}
thank you all so much!! i really appreciate it =)
@Ljuba: Thanks for helping, but you ought not to do all the work for the OP.
@Zhuge : I'm sorry.. it's not that i'm not intended to do it by myself but i really appreciated their help. I'm not using all the coding to my own work. I'm just using it as reference.
Topic archived. No new replies allowed.