エラーは、プログラムを実行して終了するように入力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;
}