Few things you can try out :
1)Read the blurred out print of the image you so nicely posted(If you can read).
2)Understand the problem and try to solve it.(If you have time)
3)Refer to some good links on the net to get more knowledge(On C++)rather than chickening out.

After you have done these do let us know...

This is my code program that I can not finished:
(Using Turbo C++ 4.5)

#include <iostream.h>
#include <string.h>

void display();
float caltotal(float,float);

void main()
{
	char loop, item[30], category;
	float price, quantity, numitem=0, s=0, m=0, total=0, buy=0;



	cout << "The Bijak Bistari Shop" << endl;

	cout << "How much item you want to buy?" << endl;
	cin >> buy;

	for (int i=0; i<buy; i++)
	{
		cout << "Item\t\t: ";
		cin>>item[i];
		cin.ignore(80,'\n');
		cout << "Category\t: ";
		cin >>category[i];
		numitem+=1;
		cout << "Price (RM)\t: ";
		cin >> price[i];
		cout << "Quantity\t: ";
		cin >> quantity[i];

		total=caltotal(price,quantity);
		cout << "Total Price (RM): " << total<<endl;
	}

	if (category=='S')
	{
	s+=1;
	}
	else if (category=='M')
	{
	m+=1;
	}







	cout << "The total number of stationary : " << s << endl;
	cout << "The total number of magazine   : " << m << endl;

	cout << "Number of item : " << numitem << "\n";

   }
}


float caltotal (float price, float quantity)
	{
		float sum;
		sum=price*quantity;
		return sum;
	}

float ave (float s, float S)
	{
		float sum;
		sum=s/S;
		return sum;
	}

Why did I come here from googling "Sigh"??

EDIT:: Tagges "sigh"

Edited 6 Years Ago by Matthew N.: n/a

On lines 9 & 10 where you declared the variables category, price and quantity, you did not declare them as arrays, but you are using them as arrays in the for loop. You probably meant to declare

char category[30];
float price[30], quantity[30];

Also why do you make these variables float: quantity, buy, numitem, s, m? (Wouldn't int be more appropriate?)

On lines 9 & 10 where you declared the variables category, price and quantity, you did not declare them as arrays, but you are using them as arrays in the for loop. You probably meant to declare

char category[30];
float price[30], quantity[30];

Also why do you make these variables float: quantity, buy, numitem, s, m? (Wouldn't int be more appropriate?)

I have change that, but still have many error.
How to make output like this: http://i291.photobucket.com/albums/ll311/afizaex/Awam/IMAG0002.jpg

Please correct the following code based on this question ASAP.This code output is not correct. Thank you.
http://i291.photobucket.com/albums/ll311/afizaex/Awam/IMAG0004.jpg

#include<iostream.h>
#include<string.h>

int outPatientCharge();
int wardedPatientCharge();

void main()
{
    char patient, codeO, codeW[10];
    int charges, days;

    cout << "Type of patients :" << endl;
    cout << "OutPatient(O)" << endl;
    cout << "WardedPatient(W)" << endl;
    cout << "\nEnter type of patient : ";
    cin >> patient;
    if (patient == 'O')
    {
        cout << "\nOutPatient types :" << endl;
        cout << "Serious(S)" << endl;
        cout << "Mild(M)" << endl;
        cout << "Normal(N)" << endl;
        cout << "\nEnter OutPatient type code : ";
        cin >> codeO;
        charges = outPatientCharge();
        cout << "\nCharges : RM " << charges << endl;
    }
    else
    if (patient == 'W')
    {
        cout << "\nWardedPatient types :" << endl;
        cout << "Surgery(W001)" << endl;
        cout << "Orthopedic(W002)" << endl;
        cout << "Medical(W003)" << endl;
        cout << "\nEnter OutPatient type code : ";
        cin >> codeW;
        cin.get (codeW, 10);
        cin.ignore (80, '\n');
        charges = wardedPatientCharge();
        cout << "\nCharges : RM " << charges << endl;
    }
    else
        cout << "\nInvalid type of patient" << endl;
}

int outPatientCharge()
{
    int charge;
    char codeO;
    if (codeO == 'S')
        {
        charge = 200;
        }
    else if (codeO == 'M')
        {
        charge = 100;
        }
    else if (codeO == 'N')
        {
        charge = 30;
        }
    return charge;
}

int wardedPatientCharge()
{
    int charge, days;
    char codeW[10];
    cout << "Number of days : ";
    cin >> days;
    if (strcmp (codeW, "W001")==0)
        charge = 300 * days;
    if (strcmp (codeW, "W002")==0)
        charge = 250 * days;
    if (strcmp (codeW, "W003")==0)
        charge = 200 * days;
    return charge;
}

Based on the following output http://i291.photobucket.com/albums/ll311/afizaex/Awam/IMAG0002.jpg , can someone help me to repair code for the highest price for magazine. I run, and it display Pencil, not Anjung Seri. ASAP, Thank you!

#include<iostream.h>
#include<string.h>
#include<math.h>



float SumItemPrice(float,int);
float aveStationaryPrice(float, int);



void main()
{

    float totalprice[40], pricestationary=0;
    int totalstationary=0, totalmagazine=0;
    char name[40][30], category[40];
    double price[40];
    int quantity[40],num_stationary=0,num_magazine=0;
    double average=0, priceall=0;
    int num_item=0;

    cout<<"\tThe Bijak Bistari Shop"<<endl;
    cout<<"\tNumber of item : ";
    cin>>num_item;
    cout<<endl;

    cin.ignore(80,'\n');

    for(int i=0; i<num_item; i++)
    {
        cout<<"\tItem            : ";
        cin.get(name[i],30);
        cin.ignore(80,'\n');

        cout<<"\tCategory          : ";
        cin>>category[i];
        cin.ignore(80,'\n');

        cout<<"\tPrice (RM)          : ";
        cin>>price[i];
        cin.ignore(80,'\n');

        cout<<"\tQuantity             : ";
        cin>>quantity[i];
              cin.ignore(80,'\n');



        totalprice[i]=SumItemPrice(price[i],quantity[i]);

        cout<<"\tTotal Price    (RM)    : "<<totalprice[i]<<endl;
        cout<<endl;

        if( category[i]=='S' )
        {
            num_stationary++;
            totalstationary=totalstationary+totalprice[i];
            pricestationary=pricestationary+price[i];
        }

        else if  ( category[i]=='M')
        {
            num_magazine++;
            totalmagazine=totalmagazine+totalprice[i];
        }
    }

    cout<<"\tThe total number of stationary\t\t: "<<num_stationary<<endl;
    cout<<"\tThe total number of magazine  \t\t: "<<num_magazine<<endl;
    cout<<endl;



    average=aveStationaryPrice(pricestationary,num_stationary);

    cout<<"\tThe average price for stationary  \t: RM "<<average<<endl;
    cout<<endl;


    double max=totalprice[0];
    for(i=0; i<num_magazine; i++)
    {
        if(totalprice[i]>max)
        max=totalprice[i];
    }


    

    int index=0;

    for(i=0; i<num_item; i++)
    {
        if(category[i]=='M')
            {
                if(max==totalprice[i])
                index=i;
            }
    }

    
    

    cout<<"\tThe highest price for magazine :"<<endl;
    cout<<"\tItem\t\t\t: "<<name[index]<<endl;
    cout<<"\tCategory\t\t: "<<category[index]<<endl;
    cout<<"\tPrice (RM)\t\t: "<<price[index]<<endl;
    cout<<endl;


    priceall=totalstationary+totalmagazine;

    cout<<"\tThe total price of stationary     : RM "<<totalstationary<<endl;
    cout<<"\tThe total price of magazine      : RM "<<totalmagazine<<endl;
    cout<<"\tThe total price of all item       : RM "<<priceall<<endl;

}




float SumItemPrice(float price,int quantity)
{
    float totalprice;
    totalprice=price*quantity;
    return totalprice;
}





float aveStationaryPrice(float priceOfStationary, int NumberOfStationary)
{
     float average;
     average=priceOfStationary / NumberOfStationary;
     return average;
}

Based on the following output http://i291.photobucket.com/albums/ll311/afizaex/Awam/IMAG0002.jpg , can someone help me to repair code for the highest price for magazine. I run, and it display Pencil, not Anjung Seri. ASAP, Thank you!

#include<iostream.h>
#include<string.h>
#include<math.h>



float SumItemPrice(float,int);
float aveStationaryPrice(float, int);



void main()
{

    float totalprice[40], pricestationary=0;
    int totalstationary=0, totalmagazine=0;
    char name[40][30], category[40];
    double price[40];
    int quantity[40],num_stationary=0,num_magazine=0;
    double average=0, priceall=0;
    int num_item=0;

    cout<<"\tThe Bijak Bistari Shop"<<endl;
    cout<<"\tNumber of item : ";
    cin>>num_item;
    cout<<endl;

    cin.ignore(80,'\n');

    for(int i=0; i<num_item; i++)
    {
        cout<<"\tItem            : ";
        cin.get(name[i],30);
        cin.ignore(80,'\n');

        cout<<"\tCategory          : ";
        cin>>category[i];
        cin.ignore(80,'\n');

        cout<<"\tPrice (RM)          : ";
        cin>>price[i];
        cin.ignore(80,'\n');

        cout<<"\tQuantity             : ";
        cin>>quantity[i];
              cin.ignore(80,'\n');



        totalprice[i]=SumItemPrice(price[i],quantity[i]);

        cout<<"\tTotal Price    (RM)    : "<<totalprice[i]<<endl;
        cout<<endl;

        if( category[i]=='S' )
        {
            num_stationary++;
            totalstationary=totalstationary+totalprice[i];
            pricestationary=pricestationary+price[i];
        }

        else if  ( category[i]=='M')
        {
            num_magazine++;
            totalmagazine=totalmagazine+totalprice[i];
        }
    }

    cout<<"\tThe total number of stationary\t\t: "<<num_stationary<<endl;
    cout<<"\tThe total number of magazine  \t\t: "<<num_magazine<<endl;
    cout<<endl;



    average=aveStationaryPrice(pricestationary,num_stationary);

    cout<<"\tThe average price for stationary  \t: RM "<<average<<endl;
    cout<<endl;


    double max=totalprice[0];
    for(i=0; i<num_magazine; i++)
    {
        if(totalprice[i]>max)
        max=totalprice[i];
    }


    

    int index=0;

    for(i=0; i<num_item; i++)
    {
        if(category[i]=='M')
            {
                if(max==totalprice[i])
                index=i;
            }
    }

    
    

    cout<<"\tThe highest price for magazine :"<<endl;
    cout<<"\tItem\t\t\t: "<<name[index]<<endl;
    cout<<"\tCategory\t\t: "<<category[index]<<endl;
    cout<<"\tPrice (RM)\t\t: "<<price[index]<<endl;
    cout<<endl;


    priceall=totalstationary+totalmagazine;

    cout<<"\tThe total price of stationary     : RM "<<totalstationary<<endl;
    cout<<"\tThe total price of magazine      : RM "<<totalmagazine<<endl;
    cout<<"\tThe total price of all item       : RM "<<priceall<<endl;

}




float SumItemPrice(float price,int quantity)
{
    float totalprice;
    totalprice=price*quantity;
    return totalprice;
}





float aveStationaryPrice(float priceOfStationary, int NumberOfStationary)
{
     float average;
     average=priceOfStationary / NumberOfStationary;
     return average;
}
This article has been dead for over six months. Start a new discussion instead.