標題:
購物系統 (四)
[打印本頁]
作者:
tonyh
時間:
2013-7-20 15:26
標題:
購物系統 (四)
新增購物清單
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍 ","可愛玩偶","籃球 "}; //商品名稱
int price[]={450,550,325,200,660,150,380}; //商品單價
int qty[]={0,0,0,0,0,0,0}; //銷售量初始值
int p,q,sum=0; //商品代碼,數量,總金額
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
cout<<"(1)遙控汽車\t450元"<<endl;
cout<<"(2)飛機模型\t550元"<<endl;
cout<<"(3)足球\t\t325元"<<endl;
cout<<"(4)拼圖\t\t200元"<<endl;
cout<<"(5)玩具槍\t660元"<<endl;
cout<<"(6)可愛玩偶\t150元"<<endl;
cout<<"(7)籃球\t\t380元"<<endl;
cout<<"(8)結帳"<<endl<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
{
goto checkout;
}else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
if(q>0)
{
sum=sum+price[p-1]*q;
qty[p-1]=q;
goto start;
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
checkout:
cout<<endl<<"[購物清單]"<<endl;
cout<<"-----------------------------"<<endl;
for(int i=0; i<=6; i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
}
cout<<"-----------------------------"<<endl;
cout<<"\t\t總共"<<sum<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃崇維
時間:
2013-7-20 15:28
本帖最後由 黃崇維 於 2013-7-20 20:32 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"一星級電腦","二星級電腦","三星級電腦","四星級電腦","五星級電腦","六星級電腦","七星級電腦"};
int price[]={10000,12000,12300,12340,12345,123456,1234567};
int qty[]={0,0,0,0,0,0,0};
int p, q, money, pay, sum=0, a;
cout<<"崇維智能電腦房屋店"<<endl<<endl;
cout<<"[電腦價目表]"<<endl;
cout<<"(1)一星級電腦\t10000元"<<endl;
cout<<"(2)二星級電腦\t12000元"<<endl;
cout<<"(3)三星級電腦\t12300元"<<endl;
cout<<"(4)四星級電腦\t12340元"<<endl;
cout<<"(5)五星級電腦\t12345元"<<endl;
cout<<"(6)六星級電腦\t123456元"<<endl;
cout<<"(7)七星級電腦\t1234567元"<<endl;
cout<<"(8)結帳"<<endl<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
{
goto checkout;
}else if(p>=1 && p<=7)
{
cout<<"請輸入數量:";
cin>>q;
if(q>0)
{
sum=sum+price[p-1]*q;
qty[p-1]=q;
goto start;
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
checkout:
cout<<endl<<"[購物清單]"<<endl;
cout<<"-------------"<<endl;
for(int i=0; i<=6; i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
}
cout<<"-------------"<<endl;
cout<<"\t\t總共"<<sum<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蘇昱安
時間:
2013-7-20 15:28
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","遙控飛機","玩具槍 ","可愛玩偶","籃球 "};
int price[]={450,550,325,200,660,150,380};
int qty[]={0,0,0,0,0,0,0};
int p,q,sum=0;
cout<<"智能玩具店"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
cout<<"(1)遙控汽車\t450元"<<endl;
cout<<"(2)飛機模型\t550元"<<endl;
cout<<"(3)足球\t\t325元"<<endl;
cout<<"(4)遙控飛機\t200元"<<endl;
cout<<"(5)玩具槍\t660元"<<endl;
cout<<"(6)可愛玩偶\t150元"<<endl;
cout<<"(7)籃球\t\t380元"<<endl<<endl;
cout<<"(8)結帳"<<endl<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
{
goto checkout;
}else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
if(q>0)
{
sum=sum+price[p-1]*q;
goto start;
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
checkout:
cout<<endl<<"[購物清單]"<<endl;
cout<<"----------------------"<<endl;
for(int i=0; i<=6; i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元*"<<qty[i]<<"個"<<endl;
}
cout<<"----------------------"<<endl;
cout<<endl<<"/t/t總共"<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
劉泳鱔
時間:
2013-7-20 15:29
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"屎一斤 ","坦克模型","魔球 ","藍圖 ","機關槍 ","驚悚玩偶","保齡球 "};
int price[]={450,550,325,200,660,150,380};
int qty[]={0,0,0,0,0,0,0};
int p,q,sum=0;
cout<<"$超能商店$"<<endl;
cout<<"[商品價格]"<<endl;
cout<<"(1)屎一斤\t550元"<<endl;
cout<<"(2)坦克模型\t550元"<<endl;
cout<<"(3)魔球\t\t325元"<<endl;
cout<<"(4)藍圖\t\t200元"<<endl;
cout<<"(5)機關槍\t660元"<<endl;
cout<<"(6)驚悚玩偶\t150元"<<endl;
cout<<"(7)保齡球\t380元"<<endl;
cout<<"(8)結帳"<<endl<<endl;
cout<<"[使用說明]"<<endl;
cout<<"依序輸入想購買的商品與數量,如籃球兩顆請輸入'7 2'"<<endl;
cout<<"選購完畢時輸入'8 8'進入結帳頁"<<endl<<endl;
start:
cout<<"在此輸入: ";
cin>>p;
if(p==8)
{
goto checkout;
}
else if(p>=1 && p<=7 && q>0)
{
sum=sum+price[p-1]*q;
qty[p-1]=q;
goto start;
}else if(p==8 && q==8)
{
goto checkout;
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
checkout:
cout<<endl<<"[購物清單]"<<endl;
cout<<"-------------------------------------"<<endl;
for(int i=0; i<=6; i++)
{
cout<<name[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
}
if(qty[i]!=0)
cout<<"-------------------------------------"<<endl;
cout<<"\t\t總共"<<sum<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林以諾
時間:
2013-7-20 15:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"四人套房 ","兩人套房 ","七人小木屋 ","孤單一人房 ","百人總統房 ","安靈病房 ","太平間地下房 ","跟泳鱔一夜情套房"};
int qty[]={0,0,0,0,0,0,0,0};
int price[]={10000,5000,50000,4444,10,1744,55,10000};
int h, q, pay, money,sum=0;
cout<<"以諾豪華九星級飯店"<<endl;
cout<<"[飯店房間價目表]"<<endl;
cout<<"(1)四人套房\t10000元"<<endl;
cout<<"(2)兩人套房\t5000元"<<endl;
cout<<"(3)七人小木屋\t50000元"<<endl;
cout<<"(4)孤單一人房\t4444元"<<endl;
cout<<"(5)百人總統房\t10元"<<endl;
cout<<"(6)安靈病房\t1744元"<<endl;
cout<<"(7)太平間地下房\t55元"<<endl;
cout<<"(8)跟泳鱔一夜情套房\t1元"<<endl;
cout<<"[付費說明]"<<endl;
cout<<"把要住的房間代號輸入後,再輸入要買幾間"<<endl;
cout<<"購買完請輸入9前往結帳"<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>h;
if(h==9)
{
goto checkout;
}
else if(h>=1 && h<=8)
{
cout<<"請輸入購買數量: ";
cin>>q;
if(q>0)
{
sum=sum+price[h-1]*q;
qty[h-1]=q;
goto start;
}
else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
}
else
{
cout<<"什麼年紀了還會輸入錯誤!!"<<endl;
goto start;
}
checkout:
cout<<"購物清單"<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$"<<endl;
for(int i=0;i<=7;i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元 *"<<qty[i]<<"個"<<endl;
}
cout<<"$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"\t\t總共是"<<sum<<"元"<<endl;
cout<<"請輸入客人付了多少錢: ";
cin>>pay;
money=pay-sum;
if(money==0)
{
cout<<"錢剛剛好! 請慢走!"<<endl;
}
if(money<0)
{
cout<<"錢不夠! 還少"<<-money<<endl;
}
if(money>0)
{
cout<<"總共需要找客人"<<money<<"元";
if(money>=500)
{
cout<<"500元鈔票"<<money/500<<"張"<<endl;
money=money%500;
}
if(money>=100)
{
cout<<"100元鈔票"<<money/100<<"張"<<endl;
money=money%100;
}
if(money>=50)
{
cout<<"50元硬幣"<<money/50<<"枚"<<endl;
money=money%50;
}
if(money>=10)
{
cout<<"10元硬幣"<<money/10<<"枚"<<endl;
money=money%10;
}
}
system("pause");
return 0;
}
複製代碼
作者:
郭凡瑛
時間:
2013-7-20 15:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name []={"小說", "漫畫", "雜誌", "字典", "百科全書",};
int price[]={300,250,150,600,1000};
int qty[]={0,0,0,0,0};
int p,q,sum=0;
cout<<"書店"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
cout<<"(1)小說\t\t300元"<<endl;
cout<<"(2)漫畫\t\t250元"<<endl;
cout<<"(3)雜誌\t\t150元"<<endl;
cout<<"(4)字典\t\t600元"<<endl;
cout<<"(5)百科全書\t1000元"<<endl;
cout<<"(6)結帳"<<endl<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==6)
{
goto checkout;
}else if(p>=1 && p<=5)
{
cout<<"請輸入數量: ";
cin>>q;
if(q>0)
{
sum=sum+price[p-1]*q;
qty[p-1]=q;
goto start;
}else
{
cout<<"輸入錯誤"<<endl;
goto start;
}
}else
{
cout<<"輸入錯誤"<<endl;
goto start;
}
checkout:
cout<<endl<<"[購物清單]"<<endl;
cout<<"-----------------------"<<endl;
for(int i=0; i<=4; i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元*"<<qty[i]<<"個"<<endl;
}
cout<<"-----------------------"<<endl;
cout<<endl<<"總共"<<sum<<"元"<<endl;
system ("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2013-7-20 15:37
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球","拼圖","玩具槍","可愛玩偶","籃球"};
int price[]={450,550,325,200,660,150,380};
int qty[]={0,0,0,0,0,0,0};
int p,q,sum=0;
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
cout<<"(1)遙控汽車\t450元"<<endl;
cout<<"(2)飛機模型\t550元"<<endl;
cout<<"(3)足球\t\t325元"<<endl;
cout<<"(4)拼圖\t\t200元"<<endl;
cout<<"(5)玩具槍\t660元"<<endl;
cout<<"(6)可愛玩偶\t150元"<<endl;
cout<<"(7)籃球\t\t380元"<<endl;
cout<<"(8)結帳"<<endl<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
{
goto checkout;
}else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
if(q>0)
{
sum=sum+price[p-1]*q;
goto start;
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
checkout:
cout<<endl<<"{垢物親單}"<<endl;
cout<<"---------------------------------"<<endl;
for(int i=0; i<=6; i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元 *"<<qty[i]<<"個"<<endl;
}
cout<<"---------------------------------"<<endl;
cout<<"\t\t總共"<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
許逸群
時間:
2013-7-20 15:37
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"空氣","石油","行星","水","陽光","黃金","泥土"};
int qty[]={0,0,0,0,0,0,0};
int price[]={450,550,1000,200,660,150,380};
int p,q,sum=0;
cout<<"☆★☆21世紀ㄟ店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
cout<<"(1)空氣\t450元"<<endl;
cout<<"(2)石油\t550元"<<endl;
cout<<"(3)行星\t1000元"<<endl;
cout<<"(4)水\t200元"<<endl;
cout<<"(5)陽光\t660元"<<endl;
cout<<"(6)黃金\t10000元"<<endl;
cout<<"(7)泥土\t380元"<<endl;
cout<<"(8)結帳"<<endl<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
{
goto checkout;
}else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
if(q>0)
{
sum=sum+price[p-1]*q;
qty[p-1]=q;
goto start;
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
checkout:
cout<<endl<<"[購物清單]"<<endl;
cout<<"------------------"<<endl;
for(int i=0; i<=6; i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元*"<<qty[i]<<"個"<<endl;
}
cout<<endl<<"總共"<<sum<<"元!"<<endl;
cout<<"------------------"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張瀚仁
時間:
2013-7-20 15:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"一日喪命散 ","含笑半步癲 ","地獄一日遊 ","地獄拔舌體驗卷","爬劍山體驗卷 ","棺材訂做 "};
int qty[]={0,0,0,0,0,0};
int price[]={1240,136,2584,251,987,654};
int a,b,sum=0,pay,money;
cout<<"***歡樂屋***"<<endl;
cout<<"商品價目表"<<endl;
cout<<"(1)一日喪命散\t\t1240元"<<endl;
cout<<"(2)含笑半步癲\t\t136元"<<endl;
cout<<"(3)地獄一日遊\t\t2584元"<<endl;
cout<<"(4)地獄拔舌體驗卷\t251元"<<endl;
cout<<"(5)爬劍山體驗卷\t\t987元"<<endl;
cout<<"(6)棺材訂做\t\t654元"<<endl;
cout<<"死亡一概不負責,消費滿5000送棺材乙個!!(限量 鍍金市價10000元)"<<endl;
cout<<"選購完時代號都輸入8即可進入結帳頁"<<endl;
start:
cout<<"請輸入商品代號:"<<endl;
cin>>a;
if(a==8)
{
goto end;
}
cout<<"請輸入數量:"<<endl;
cin>>b;
if(a>=1 && a<=7 && b>0)
{
sum=sum+price[a-1]*b;
qty[a-1]=b;
goto start;
}else
{
cout<<"輸入錯誤"<<endl;
goto start;
}
end:
cout<<endl<<"[購物清單]"<<endl;
cout<<"-------------------------------"<<endl;
for(int i=0;i<=5;i++)
{
if(qty[i]!=0)
{
cout<<name[i]<<"\t"<<price[i]<<"*"<<qty[i]<<"個"<<endl;
}
}
cout<<"-------------------------------"<<endl;
cout<<endl<<"\t\t總共"<<sum<<"元!"<<endl;
if(sum>=5000)
{
cout<<"由於消費滿5000,贈送鍍金棺材乙個!!"<<endl;
}
cout<<"請輸入付了多少錢: ";
cin>>pay;
money=pay-sum;
if(money==0)
{
cout<<"錢剛剛好! 請慢走!"<<endl;
}
if(money<0)
{
cout<<"錢不夠! 還欠"<<-money<<endl;
}
if(money>0)
{
cout<<"總共需要找客人"<<money<<"元";
if(money>=500)
{
cout<<"500元鈔票"<<money/500<<"張"<<endl;
money=money%500;
}
if(money>=100)
{
cout<<"100元鈔票"<<money/100<<"張"<<endl;
money=money%100;
}
if(money>=50)
{
cout<<"50元硬幣"<<money/50<<"枚"<<endl;
money=money%50;
}
if(money>=10)
{
cout<<"10元硬幣"<<money/10<<"枚"<<endl;
money=money%10;
}
if(money>=5)
{
cout<<"5元硬幣"<<money/5<<"枚"<<endl;
money=money%5;
}
if(money>=1)
{
cout<<"1元硬幣"<<money/1<<"枚"<<endl;
money=money%1;
}
}
system("pause");
return 0;
}
複製代碼
作者:
黃柏維
時間:
2013-7-20 15:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
int price[]={450,550,325,200,660,150,380};
int qty[]={0,0,0,0,0,0,0};
int p,q,pay,money,sum=0;
cout<<"***智能玩具店***"<<endl;
cout<<"**商品價目表**"<<endl;
cout<<"(1)遙控汽車\t450元"<<endl;
cout<<"(2)飛機模型\t550元"<<endl;
cout<<"(3)足球\t\t325元"<<endl;
cout<<"(4)拼圖\t\t200元"<<endl;
cout<<"(5)玩具槍\t660元"<<endl;
cout<<"(6)可愛玩偶\t150元"<<endl;
cout<<"(7)籃球\t\t380元"<<endl;
cout<<"(8)結帳"<<endl;
cout<<"$$請選擇你要的商品$$"<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
goto checkout;
else
{
cout<<"數量: ";
cin>>q;
if(p>=1 && p<=7 && q>0)
{
sum=sum+price[p-1]*q;
qty[p-1]=q;
goto start;
}
else
{
cout<<"輸入錯誤"<<endl;
goto start;
}
}
checkout:
cout<<"[購物清單]"<<endl<<endl;
cout<<"------------------------------"<<endl;
for(int i=0;i<=6;i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元 *"<<qty[i]<<"個"<<endl;
}
cout<<"------------------------------"<<endl;
cout<<"\t\t"<<"總共"<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2013-7-20 15:45
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
int price[]={450,550,325,200,660,150,380};
int qty[]={0,0,0,0,0,0,0};
int p,q,sum=0;
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
cout<<"(1)遙控汽車\t450元"<<endl;
cout<<"(2)飛機模型\t550元"<<endl;
cout<<"(3)足球\t\t325元"<<endl;
cout<<"(4)拼圖\t\t200元"<<endl;
cout<<"(5)玩具槍\t660元"<<endl;
cout<<"(6)可愛玩偶\t150元"<<endl;
cout<<"(7)籃球\t\t380元"<<endl;
cout<<"(8)結帳"<<endl<<endl;
start:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
{
goto checkout;
}else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
if(q>0)
{
sum=sum+price[p-1]*q;
qty[p-1]=q;
goto start;
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
}else
{
cout<<"輸入錯誤!"<<endl;
goto start;
}
checkout:
cout<<endl<<"{垢物親單}"<<endl;
cout<<"---------------------------------"<<endl;
for(int i=0; i<=6; i++)
{
if(qty[i]!=0)
cout<<name[i]<<"\t"<<price[i]<<"元 *"<<qty[i]<<"個"<<endl;
}
cout<<"---------------------------------"<<endl;
cout<<"\t\t總共"<<sum<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2