im a noobs in c++.. and my problem is i cant calculate the total,.. here is my program.... i use MSVC++ 6.0.. i hope you can solve my problem..thank you!!.

#include<iostream.h>

void line();
void main()


{
	cout<<"\t\tlist of foods:\n\n1. Yum..............................P49.00\n2. Yum w/ Cheese....................P59.00\n3. Yum with Mushroom and Cheese.....P66.00\n4. Amazing Aloha....................P88.00\n5. Palabok Fiest....................P67.00\n6. Jolly Spaghetti..................P76.00\n\n";

	int item[10];
	char indicator='y';
	
	char string[10];
	double price[10],qty[10],charge=0,total=0,overtal=0;
	int n=0, counter=0;

	cout<<"YOURNAME:\t";
	cin>>string;
	cout<<"\n";

	while( (indicator == 'y' || indicator == 'Y') )
   {
	cout<<"Enter the item number:";
	cin>>item[n];

	if (item[n]==1) {
	cout<<"price the is: P49.00 \n";
	price[n]=49.00;
	}
	else if (item[n]==2) {
	cout<<"price the is: P59.00 \n";
	price[n]= 59.00;
	}
       else if (item[n]==3) {
	cout<<"price the is: P66.00 \n";
	price[n] = 66.00;
	}
       else if (item[n]==4) {
	cout<<"price the is: P88.00 \n";
	price[n]= 88.00;
	}
       else if (item[n]==5) {
	cout<<"price the is: P67.00 \n";
	price[n]= 67.00;
	}
       else if (item[n]==6) {
	cout<<"price the is: P76.00 \n";
	price[n]=76.00;
	}
	counter++;
	cout<<"Enter the Quantity: ";cin>>qty[n];
	cout << "Do you want to enter another(y or n)? ";cin >> indicator;
	cout<<"\n"; n++;
	total=price[n] * qty[n];
	

    }

	


	line();
	cout<<"\t\t\t OFFICIAL RECEIPT\n";
	line();
	cout<<"\n";

	cout<<"NAME: ";
	cout<<"\t"<<string<<"\n";

	cout<<"INVOICE\t\t\t\tPrice\n";

	n=0;
	while(n<counter)
	{
	cout<<"\t"<<item[n]<<"\t\t\t\t"<<price[n]<<"\n";
	cout<<"\t"<<"Quantity"<<"\t\t\t"<<qty[n]<<"\n\n";
	total+=(price[n]*qty[n]);
	overtal+=total;
	n++;

	}
	cout<<"TOTAL\t\t\t\t\t"<<overtal<<"\n\n";


}
void line()
{
cout<<"\t\t\t_________________\n";
}

As you get the input from user, you never update the quantity array.

And, that array should be set to all zeros when you declare it, otherwise you would be incrementing starting at random values.

As you get the input from user, you never update the quantity array.

And, that array should be set to all zeros when you declare it, otherwise you would be incrementing starting at random values.

ahmm if u dont mind boss can you put the corect code?.. i just want to know the exact code of mine...:D

Please stop calling us "boss". We aren't your boss.

To initialize the array to zeros: double qty[10] = {0.0}; But qty shouldn't be an array of ints instead of doubles, or are you allowed to buy fractions of sojmething?

Please stop calling us "boss". We aren't your boss.

To initialize the array to zeros: double qty[10] = {0.0}; But qty shouldn't be an array of ints instead of doubles, or are you allowed to buy fractions of sojmething?

ah.. sorry for that sir...
no, its not allowed to buy fractions of something...

thanks for that info.. ill try that as soon as possible...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.