標題:
購物系統 (二)
[打印本頁]
作者:
王瑞喻
時間:
2019-10-12 09:34
標題:
購物系統 (二)
本帖最後由 王瑞喻 於 2019-10-12 12:19 編輯
新增 "請輸入商品代碼:" 與 "數量:" 的選項,
並於結帳時計算出總共多少錢, 執行畫面如下圖所示.
本帖隱藏的內容需要回復才可以瀏覽
作者:
洪榜蔓
時間:
2019-10-12 11:39
#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 if(p==8)
{
goto checkout;
}
checkout:
cout<<"總金額: "<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
曾宥程
時間:
2019-10-12 12:11
本帖最後由 曾宥程 於 2019-10-19 08:16 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string item[]={"koreafish(一盒87隻) ","花媽造型餅乾(一盒87片)","馬櫻酒 ","館長牌雞肉 "
,"空心蔡英文 ","柯P的手表 ","'蝦子'小餅乾 ",};
int price[]={1450,870,690,399,150,5000,450,0};
cout<<"======???????店======"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int p,q,sum=0;
for(int i=0; i<7; i++)
cout<<"("<<i+1<<")"<<item[i]<<"\t"<<price[i]<<"元"<<endl;
cout<<"<8>結帳"<<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 if(p==8)
{
goto checkout;
}else
{
cout<<"輸入錯誤!!!!!!!!!!!"<<endl;
goto re;
}
checkout:
cout<<"總金額是"<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡少宇
時間:
2019-10-14 21:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"ALTIS","RAV4 ","CAMRY","YARIS","AURIS","C-HR ","SUPRA"};
int price[]={750000,1200000,920000,585000,850000,850000,2030000};
cout<<"☆★☆TOYOTA商場 ☆★☆"<<endl<<endl;
cout<<"【商品價目表】"<<endl;
int p,q,sum=0;
for(int i=0; i<7; i++)
cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
cout<<"(8)結帳"<<endl<<endl;
cout<<"輸入<8>開始結帳"<<endl<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p>=1 && p<=7)
{
cout<<"請輸入商品數量: ";
cin>>q;
cout<<endl;
if(q>0)
{
sum=sum+price[p-1]*q;
goto re;
}else
{
cout<<"輸入錯誤誤誤...!!"<<endl;
cout<<endl;
goto re;
}
}else if(p==8)
{
goto checkout;
}else
{
cout<<"輸入錯誤誤誤...!!"<<endl;
cout<<endl;
goto re;
}
checkout:
cout<<endl;
cout<<"總金額是: "<<sum<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳宇柏
時間:
2019-10-15 17:26
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"***智能玩具店***"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
string a[5]={"bmw","法拉利","藍寶潔尼 ",
"賓士 ","奧迪 "};
int price[5]={400,550,600,250,150,};
int p,q,sum=0;
for(int i=0;i<5;i++)
{
cout<<"("<<i+1<<")"<<a[i]<<"\t"<<price[i]<<"萬元"<<endl;
}
cout<<"(6)結帳"<<endl<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>> p;
if(p>=1 && p<=5)
{
cout<<"數量: ";
cin>> q;
if(q>0)
{
sum= sum+ price[p-1]*q;
goto re;
}
}else if(p==6)
{
goto checkout;
}
else
{
cout<<"error"<<endl;
goto re;
}
checkout:
cout<<"總金額: "<<sum<<"萬元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
王建葦
時間:
2019-10-18 19:01
本帖最後由 王建葦 於 2019-10-19 10:03 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"Millet "
,"SONY "
,"Samsung "
,"OPPO "
,"APPLE "
,"Koreafish "
,"ASUS "
,"VegetablesEnglish"};
int price[]={9000,7000,7000,8000,50000,0,9000,0};
cout<<"=====不知道賣什麼的專賣店====="<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int p,q,sum=0;
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>=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;
}
複製代碼
作者:
王翎璇
時間:
2019-10-18 22:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍","可愛玩偶","籃球 "};
int price[]={450,550,325,200,660,150,380};
cout<<"***智能玩具店***"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int p,q,sum=0;
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>=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;
}
複製代碼
作者:
鄭羽捷
時間:
2019-10-18 22:59
本帖最後由 鄭羽捷 於 2019-10-19 09:03 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍","可愛玩偶","籃球 "};
int price[]={450,550,325,200,660,150,380};
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int p,q,sum=0;
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>=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;
}
複製代碼
作者:
洪子涵
時間:
2019-10-18 23:22
本帖最後由 洪子涵 於 2019-10-19 10:47 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍","可愛玩偶","籃球 "};
int mn[]={450,550,325,200,660,150,380};
cout<<"智能玩具店"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int n,q,sum=0;
for(int i=0; i<7; i++)
{
cout<<"("<<i+1<<")"<<name[i]<<"\t"<<mn[i]<<"元"<<endl;
}
cout<<"(8)結帳"<<endl<<endl;
re:
cout<<"請輸入商品代碼:";
cin>>n;
if(n>=1 && n<=7)
{
cout<<"數量:";
cin>>q;
if(q>0)
{
sum=sum+mn[n-1]*q;
goto re;
}else
{
cout<<"輸入錯誤"<<endl;
goto re;
}
}
else if(n==8)
{
goto checkout;
}else
{
cout<<"輸入錯誤"<<endl;
goto re;
}
checkout:
cout<<"總金額:"<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
郭哲維
時間:
2019-10-19 10:04
#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 if(p==8)
{
goto checkout;
}
checkout:
cout<<"總金額: "<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪藜芸
時間:
2019-10-19 10:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b,c=0;
cout<<"◎◎◎玩具店◎◎◎"<<endl<<endl<<"[商品價目表]"<<endl;
string t[8]={"遙控汽車","飛機模型","足球","拼圖","玩具槍","可愛玩偶","籃球","結帳"};
int p[7]={450,550,325,200,660,150,380};
for(int i=0;i<7;i++)
{
cout<<"〈"<<i+1<<"〉"<<t[i]<<"\t";
cout<<p[i]<<"元"<<endl;
}
cout<<"〈8〉結帳"<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>>a;
if(a > 0 && a < 8)
{
cout<<"數量: ";
cin>>b;
a=p[a-1];
c+=a*b;
goto re;
}else if(a==8)
{
cout<<"總共"<<c<<"元"<<endl;
}else
{
cout<<"輸入錯誤!!!"<<endl;
goto re;
}
system("pause");
return 0;
}
複製代碼
作者:
洪榜蔓
時間:
2019-10-19 10:49
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍","可愛玩偶","籃球 "};
int price[]={450,550,325,200,660,150,380};
cout<<"❦❦❦智能玩具店❦❦❦"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int p,q,sum=0;
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>=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;
}
複製代碼
作者:
郭哲維
時間:
2019-10-19 10:49
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ",
"玩具槍 ","可愛玩偶","籃球 "};
int price[]={450,550,325,200,660,150,380};
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int p,q,sum=0;
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>=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;
}
複製代碼
作者:
林孟蓁
時間:
2019-10-19 11:48
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍","可愛玩偶","籃球 "};
int price[]={450,550,325,200,660,150,380};
cout<<"***智能玩具店***"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int p,q,sum=0;
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>=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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2