#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int p,q,sum=0;
string name[]={"笑氣 ","雄商飛彈","核彈 ","拼圖飛機","羽毛球","乒乓球","籃球 "};
int price[]={45000,55000,32500,20000,66000,15000,38000};
cout<<"***智能玩具店***"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
for(int i=0; i<7; i++)
cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
cout<<"(8)結帳"<<endl<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
{
goto checkout;
}else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
sum+=price[p-1]*q;
goto re;
}else
{
goto re;
}
checkout:
cout<<endl<<"總共"<<sum<<"元!"<<endl<<endl;
system("pause");
return 0;
} |