標題:
購物系統 (二)
[打印本頁]
作者:
陳品肇
時間:
2018-10-11 21:15
標題:
購物系統 (二)
本帖最後由 陳品肇 於 2018-10-20 17:14 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
string a[7]={"遙控器車","飛機模型","足球 ",
"拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
int price[7]={450,550,325,200,660,
150,380 };
int p,q,sum=0; //p商品代碼 q商品數量
for(int i=0;i<7;i++)
{
cout<<"("<<i+1<<")"<<a[i]<<"\t"<<price[i]<<"元"<<endl;
}
cout<<"(8)結帳"<<endl<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>> p;
if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>> q;
if(q>0) //數量>0
{
sum= sum+ price[p-1]*q; //計算總金額
goto re;
}else //數量<0
{
cout<<"您輸入的數量有誤!!"<<endl;
goto re;
}
}else if(p==8)
{
goto checkout;
}else
{
cout<<"您輸入的代碼有錯!!"<<endl;
goto re;
}
checkout:
cout<<"總金額: "<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡依宸
時間:
2018-10-20 17:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string n[7]={"遙控汽車","飛機模型","足球 ","拼圖 ",
"玩具槍","可愛玩偶","籃球 "};
int m[7]={100,200,300,400,500,600,700};
int p,q,sum=0;
cout<<"☆★☆ 智障玩具店 ☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
for(int i=0; i<=6; i++)
{
cout<<"("<<i+1<<")"<<n[i]<<"\t"<<m[i]<<"元"<<endl;
}
cout<<"結帳"<<endl;
re:
cout<<"請輸入代號";
cin>>p;
if(p>=1 && p<=7)
{
cout<<"阿數量哩";
cin>>q;
if(q>0)
{
sum+=q*m[p-1];
goto re;
}else
{
cout<<"打屁阿";
goto re;
}
}else if(p==8)
{
goto pp;
}else
{
cout<<"白癡"<<endl;
goto re;
}
pp:
cout<<sum<<"元,把錢吐出來"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡季庭
時間:
2018-10-20 17:25
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
string a[7]={"遙控器車","飛機模型","足球 ",
"拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
int price[7]={450,550,325,200,660,
150,380 };
int p,q,sum=0;
for(int i=0;i<7;i++)
{
cout<<"("<<i+1<<")"<<a[i]<<"\t"<<price[i]<<"元"<<endl;
}
cout<<"(8)結帳"<<endl<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>> p;
if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>> q;
if(q>0)
{
sum= sum+ price[p-1]*q;
goto re;
}else
{
cout<<"您輸入的數量有誤!!"<<endl;
goto re;
}
}else if(p==8)
{
goto checkout;
}else
{
cout<<"您輸入的代碼有錯!!"<<endl;
goto re;
}
checkout:
cout<<"總金額: "<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳柏霖
時間:
2018-10-25 17:27
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[7]={"遙控器車","飛機模型","足球 ","拼圖 ","玩具槍","可愛玩偶","籃球 "};
int dollar[7]={450,550,325,200,660,150,300};
int x ,z ,s=0;
cout<<"[商品名稱]"<<endl;
for(int i=0; i<7; i++)
{
cout<<"("<<i+1<<")"<<name[i]<<"\t"<<dollar[i]<<"元"<<endl;
}
cout<<"(8)結帳"<<endl<<endl;
re:
cout<<"請輸入商品代碼:";
cin>>x;
if(x>=1 && x<=7)
{
cout<<"請輸入商品數量:";
cin>>z;
s+=dollar[x-1]*z;
goto re;
}else if(x==8)
{
cout<<"總共"<<s<<"元!!!"<<endl;
}else
{
cout<<"輸入錯誤!"<<endl;
goto re;
}
system("pause");
return 0;
}
複製代碼
作者:
譚詩澐
時間:
2018-10-27 10:33
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
string a[7]={"遙控器車","飛機模型","足球 ",
"拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
int price[7]={450,550,325,200,660,
150,380 };
int p,q,sum=0;
for(int i=0;i<7;i++)
{
cout<<"("<<i+1<<")"<<a[i]<<"\t"<<price[i]<<"元"<<endl;
}
cout<<"(8)結帳"<<endl<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>>p;
if (p>=1&&p<=7)
{
cout<<"數量: ";
cin>>q;
sum+=price[p-1]*q;
}else if (p==8)
goto checkout;
else
{
cout<<"輸入錯誤!"<<endl;
goto re;
}
checkout:
cout<<endl<<"總共"<<sum<<"元!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴安利
時間:
2018-10-27 10:44
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a, b, sum=0;
string name[7]={"遙控汽車","飛機模型","足球 ","拼圖 ",
"玩具槍 ","可愛玩偶","籃球 "};
int price[7]={450,550,325,200,660,150,380};
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>>a;
if(a>=1 && a<=7)
{
cout<<"數量:";
cin>>b;
sum+=price[a-1]*b;
goto re;
}else if (a==8)
goto checkout;
else
{
cout<<"輸入錯誤!!!"<<endl;
goto re;
}
checkout:
cout<<endl<<"總共"<<sum<<"元"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴唯陞
時間:
2018-10-27 10:57
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a, b, sum=0;
string name[7]={"遙控汽車","飛機模型","足球 ","拼圖 ",
"玩具槍 ","可愛玩偶","籃球 "};
int price[7]={450,550,325,200,660,150,380};
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>>a;
if(a>=1 && a<=7)
{
cout<<"數量:";
cin>>b;
sum+=price[a-1]*b;
goto re;
}else if (a==8)
goto checkout;
else
{
cout<<"輸入錯誤!!!"<<endl;
goto re;
}
checkout:
cout<<endl<<"總共"<<sum<<"元"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴偉宸
時間:
2018-10-27 10:57
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int p,q,sum=0;
string name[7]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
int price[7]={450,550,325,200,660,150,380} ;
cout<<"智能玩具店"<<endl;
cout<<"[商品價目表]"<<endl;
for(int i=0;i<7;i++)
cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
cout<<"(8)結帳"<<endl;
re:
cout<<"請輸入商品代碼 :";
cin>>p;
if(p>=1 && p<=7)
{
cout<<"數量 :";
cin>>q;
sum=sum+price[p-1]*q;
goto re;
}
else if(p==8)
goto checkout;
else
{
cout<<"輸入錯誤!"<<endl;
goto re;
}
checkout:
cout<<endl<<"總共"<<sum<<"元!"<<endl<<endl;
system("pause");
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2