OK PEOPLE I NEED HELP AGAIN........pls dont do my homework..........thats y i havnt given the question this time aroung :)
the question im asking is simple :
the program asks user to input product id ( a,b,c,d or e) and its quantity sold......it then saves total sale in "int sale"
but y doesnt the "do while" loop terminate upon entering "\r" (enter)
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int main()
{
float A=7.98,B=3.22,C=5.59,D=8.71,E=2.33; //prices of products
char ch; //identity of product
int sold; //no. of sold product
float sale=0; //total sale
do{
cout<<"\n Enter product code( a,b,c,d,e ),followed by quantity of product sold"<<endl;
cout<<" Or press Enter twice for total"<<endl;
cin>>ch>>sold;
switch (ch)
{
case 'a':
sale=+A*sold;
break;
case 'b':
sale=+B*sold;
break;
case 'c':
sale=+C*sold;
break;
case 'd':
sale=+D*sold;
break;
case 'e':
sale=+E*sold;
break;
default:
cout<<"Invalid product"<<endl;
}
}while ( ch != '\r' || sold!='\r');
cout<<"\n Total sales equal"<<sale;
getch();
return 0;
}