Help me to build this program by using Turbo C++, thank you;

User will enter car type and package of car based on the following;

-------------------------------

TYPE...PACKAGE..PRICE.........TAX
_______________________________
CAR1.......a............24000.........150%
.................b............28000.........150%
_______________________________
CAR2........c............35000.........200%
.................d............37000.........200%
.................e............41000.........200%
-------------------------------

This program will calculate new price for the type of cars after being taxed.
This program will display type of car, package and the price that has to paid by the customer.
This program will continue until user request to stop.

At the end; the program will display:
-number of customer for CAR1 type
-number of customer for CAR2 type
-total sales for CAR1 type
-total sales for CAR2 type
-total sales for all cars

Edited 6 Years Ago by afizaex: n/a

so what you have above is called the problem scenario.So you need to analyze the
problem and model the data structures.You can use the help of UML for that.

Just sketch a simple UML for the data model will help you a lot.

However let's rush into C++ code(because I don't have to do your homework).
Well CarType is a class. and CAR1 and CAR2 are instances of it.
inside that there are composites of tuples <package,prize,tax>.
So Package is another class (type) and a,b,c are instances of it.

A object like CAR1 can contain more than 1 packages, I to implement it
you can use std::vector.

Then the customers are also instances of Customer class.customers can
buy any number of packages , or stay without buying them.
so you can store customer customer ID's inside each package.

So that's how you could decompose the data into a small parts.Make it
simple.

First at least try to draw the UML data model , I'll help you.

All was done, but I cannot display the:
-total sales for CAR1 type
-total sales for CAR2 type
-total sales for all cars

Help me to solve it..

#include <iostream.h>
void main()
{
        char loop, type, package;
        float price, tax, total;
        int compact=0, sedan=0, compact_all;

        do
        {

        cout << "\nChoose type: (C) COMPACT or (S) SEDAN =" << endl;
        cin >> type;

        if (type=='C')
                {
                cout << "Choose package: (a) Standard, (B) Limited edition = " << endl;
                cin >> package;
                compact=compact+1;

                if (package=='a')
                        {
                        price=24000;
                        tax=price*1.5;
                        }
                else if (package=='b')
                        {
                        price=28000;
                        tax=price*1.5;
                        }
                else
                         {
                         cout << "Error" << endl;
                         }
                }

        else if(type=='S')
        {
                cout << "Choose package: (a) Standard, (B) Sporty, (c) Limited edition = " << endl;
                cin >> package;

      if (package=='a')
                        {
                        price=35000;
                        tax=price*2;
                        }
                else if (package=='b')
                        {
                        price=37000;
                        tax=price*2;
                        }
                else if (package=='c')
                        {
                        price=41000;
                        tax=price*2;
                        }
                else
                         {
                         cout << "Error" << endl;
                         }
                }

        else
                {
                cout << "Error" << endl;
                }

        total=price+tax;
        cout << "Total price: RM" << total << endl;

   cout << "\n Do you want to stop? (Y/N): ";
                cin >> loop;
        }
        while (loop!='Y');

        if ((type=='C') && (loop=='N'))
        compact_all=compact+0;
        cout << "Number of Compact customers: " << compact << endl;
}
#include <iostream.h>
void main()
{
	char loop, type, package;
	float price, tax, total;
	int compact=0, sedan=0, compact_all;

	do
	{

	cout << "\nChoose type: (C) COMPACT or (S) SEDAN =" << endl;
	cin >> type;

	if (type=='C')
		{
		cout << "Choose package: (a) Standard, (B) Limited edition = " << endl;
		cin >> package;
		if (package=='a')
			{
			price=24000;
			tax=price*1.5;
			compact=compact+1;
			}
		else if (package=='b')
			{
			price=28000;
			tax=price*1.5;
			compact=compact+1;
			}
		else
			 {
			 cout << "Error" << endl;
			 }
		}

	else if(type=='S')
	{
		cout << "Choose package: (a) Standard, (B) Sporty, (c) Limited edition = " << endl;
		cin >> package;

      if (package=='a')
			{
			price=35000;
			tax=price*2;
			sedan=sedan+1;
			}
      else if (package=='b')
			{
			price=37000;
			tax=price*2;
			sedan=sedan+1;
			}
		else if (package=='c')
			{
			price=41000;
			tax=price*2;
			sedan=sedan+1;
			}
		else   {
			 cout << "Error" << endl;
			 }
		}

	else
	{
	cout << "Error" << endl;
	}

	total=price+tax;
	cout << "Total price: RM" << total << endl;
	cout << "\n Do you want to stop? (Y/N): ";
	cin>>loop;
	}while (loop!='Y');


	
	cout << "Number of Compact customers: " << compact << endl;
        cout << "Number of Sedan customers: " << sedan << endl;

}

Best Of Luck.

The code that I make do not have error and same output as your modification, how about I want to display the:
-total sales for Compact type
-total sales for Sedan type
-total sales for all cars

#include <iostream.h>
void main()
{
	char loop, type, package;
	float price, tax, total;
	int compact=0, sedan=0, compact_all;
	int com_a=0,com_b=0,sed_a=0,sed_b=0,sed_c=0;
	do
	{

	cout << "\nChoose type: (C) COMPACT or (S) SEDAN =" << endl;
	cin >> type;

	if (type=='C')
		{
		cout << "Choose package: (a) Standard, (B) Limited edition = " << endl;
		cin >> package;
		if (package=='a')
			{
			price=24000;
			tax=price*1.5;
			compact=compact+1;
			com_a+=1;
			}
		else if (package=='b')
			{
			price=28000;
			tax=price*1.5;
			compact=compact+1;
			com_b+=1;
			}
		else
			 {
			 cout << "Error" << endl;
			 }
		}

	else if(type=='S')
	{
		cout << "Choose package: (a) Standard, (B) Sporty, (c) Limited edition = " << endl;
		cin >> package;

      if (package=='a')
			{
			price=35000;
			tax=price*2;
			sedan=sedan+1;
			sed_a+=1;
			}
      else if (package=='b')
			{
			price=37000;
			tax=price*2;
			sedan=sedan+1;
			sed_b+=1;
			}
		else if (package=='c')
			{
			price=41000;
			tax=price*2;
			sedan=sedan+1;
			sed_c+=1;
			}
		else   {
			 cout << "Error" << endl;
			 }
		}

	else
	{
	cout << "Error" << endl;
	}

	total=price+tax;
	cout << "Total price: RM" << total << endl;
	cout << "\n Do you want to stop? (Y/N): ";
	cin>>loop;
	}while (loop!='Y');

	float t_com_a=0.0,t_com_b=0.0,t_sed_a=0.0,t_sed_b=0.0,t_sed_c=0.0;
	t_com_a=24000*com_a+24000*com_a*1.5;
	t_com_b=27000*com_b+27000*com_b*1.5;
	t_sed_a=35000*sed_a+35000*sed_a*2;
	t_sed_b=37000*sed_b+37000*sed_b*2;
	t_sed_c=41000*sed_c+41000*sed_c*2;

	cout<<"TYPE\t"<<"PACKAGE\t"<<"PRICE\t"<<"TAX\t"<<"Quantity\t"<<"Total\n\n";
	cout<<"__________________________________________________________________________\n";
	cout << "Compact\t" <<"a\t"<<"24000\t" <<"150%\t"<<com_a<<"\t\t"<<t_com_a<<endl;
	cout << "Compact\t" <<"b\t"<<"28000\t" <<"150%\t"<<com_b<<"\t\t"<<t_com_b<<endl;
	cout<<"__________________________________________________________________________\n";
	cout<<"Total Number Of Compact : "<<compact<<"\t\tTotal Price :"<<t_com_a+t_com_b<<endl;
	cout<<"__________________________________________________________________________\n";

	cout << "Sedan\t" <<"a\t"<<"35000\t" <<"200%\t"<<sed_a<<"\t\t"<<t_sed_a<<endl;
	cout << "Sedan\t" <<"b\t"<<"37000\t" <<"200%\t"<<sed_b<<"\t\t"<<t_sed_b<<endl;
	cout << "Sedan\t" <<"c\t"<<"41000\t" <<"200%\t"<<sed_c<<"\t\t"<<t_sed_c<<endl;
	cout<<"__________________________________________________________________________\n";
	cout<<"Total Number Of Sedan : "<<sedan<<"\t\tTotal Price :"<<t_sed_a+t_sed_b+t_sed_c;
}

Use some more variable to store number sale for all the type of car.
Best of Luck.

Use this for total of all type of and there price

cout<<"Total Number of all Car : "<<sed_a+sed_b+sed_c+com_a+com_b<<"\t\t\tTotal Price : "<<t_sed_a+t_sed_b+t_sed_c+t_com_a+t_com_b;

That's I want the program look like, I cannot think it will be like this. Thank you very much!

This question has already been answered. Start a new discussion instead.