错误是当我运行程序并键入n
结束时选择它不会结束并不断重复第一个cout
和默认值:
#include <iostream>
using namespace std;
int main()
{
int x;
float y,result=0,paid,change;
do {
cout<<"enter another choose or press (n/N) to end choosing ";
cin>>x;
switch (x)
{
case 1:
{
int a=5;
cout<<"enter the wighte you want in (Kg) : ";
cin>>y;
result=a*y;
break;}
default:
cout<<"wrong choooose "<<endl;
}
}
while (x='n');
cout<<"your total= "<<result<<endl;
cout<<"mony value paid = ";
cin>>paid;
change =paid-result;
cout<<"the change = "<<change<<endl;
return 0;
}