標題:
[作業] 購物系統 [五]
[打印本頁]
作者:
tonyh
時間:
2015-3-28 11:50
標題:
[作業] 購物系統 [五]
本帖最後由 tonyh 於 2015-9-18 21:03 編輯
改寫現有購物系統, 使其搭配
促銷方案
.
譬如: 消費滿三千送炫光溜溜球乙個, 消費滿萬送千元折價券, 滿五千享9折優惠... 等等.
自由發揮!
[attach]1189[/attach]
本帖隱藏的內容需要回復才可以瀏覽
作者:
李知易
時間:
2015-4-4 11:35
本帖最後由 李知易 於 2015-4-11 11:03 編輯
#include<iostream>
#include<cstdlib>
#include "math.h"
using namespace std;
int main()
{
allre:
system("cls");
int p,pay,popo,money,opt,sum=0;
string name[5]={"砍頭優惠卷","特效搖頭丸","自殺體驗卷","被打免費票","舒柔鼻涕蟲",};
int price[5]={499,1998,8888,9999,99999};
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
int qty[5]={0,0,0,0,0};
for(int i=0; i<5; 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>>popo;
if(popo<=0)
{
cout<<"輸入錯誤!"<<endl;
goto re;
}
sum+=price[p-1]*popo;
qty[p-1]+=popo;
}
else
{
cout<<"輸入錯誤!"<<endl;
}
goto re;
checkout:
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;
if(sum >= 5000)
{
cout<<"你消費"<<sum<<"元,恭喜你符合滿5000打九折優惠活動!"<<endl<<endl;
cout<<"這一次的消費讓你省下!"<<(sum - round(sum * 0.9))<<"元"<<endl<<endl;
sum = round(sum * 0.9);
}
else if(sum >= 4500)
{
cout<<"你消費"<<sum<<"元,恭喜你符合滿4500送砍頭優惠卷活動!"<<endl<<endl;
}
cout<<"總共"<<sum<<"元!"<<endl<<endl;
cout<<"1-正確無誤"<<endl<<"2-重新選購"<<endl;
cin>>opt;
if(opt==1)
{
goto change;
}
if(opt==2)
{
goto allre;
}
change:
cout<<"請付錢:";
cin>>pay;
if(pay<=0)
{
cout<<endl<<"你是誰啊?!"<<endl<<endl;
goto change;
}
money=pay-sum;
if(money<0)
{
cout<<endl<<"錢不夠喔! 還差"<<-money<<"元!"<<endl<<endl;
goto change;
}else if(money==0)
{
cout<<endl<<"剛剛好! 銘謝惠顧!"<<endl<<endl;
}else if(money>=1000)
{
cout<<endl<<"錢太多? 全部送我吧!"<<endl<<endl;
goto change;
}
else
{
cout<<endl<<"需找客人"<<money<<"元"<<endl<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500; //money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>=1)
{
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
洪振庭
時間:
2015-4-5 19:00
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re2:
int p,q,sum=0,option,pay,money;
string name[7]={"速效跳課糖","米你毛毛球","無頭帽","金斯雀奶油蛋糕","攜帶型沼澤","假魔杖","伸縮耳"};
int price[7]={90,80,74,3,80,1,4};
int qty[7]={0,0,0,0,0,0,0};
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;
cout<<"[加隆任務]消費100加隆送假魔丈*30"
re:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
goto checkout;
else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
if(q<=0)
{
cout<<"錯誤!"<<endl;
goto re;
}
sum+=price[p-1]*q;
qty[p-1]+=q;
}
else
{
cout<<"錯誤!"<<endl;
}
goto re;
checkout:
cout<<endl<<"[魔法清單]"<<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;
if(sum >= 100)
{
cout<<"你消費"<<sum<<"加隆,符合滿100加隆的任務"<<endl<<endl;
cout<<"假魔丈*30是你的了!"<<endl;
}
cout<<"總共"<<sum<<"加隆!"<<endl<<endl;
cout<<"1-正確無誤 2-重新選購 ";
cin>>option;
if(option==1)
{
goto change;
}
else
{
system("cls");
goto re2;
}
change:
cout<<endl<<"請付帳: ";
cin>>pay;
money=pay-sum;
if(money==0)
{
cout<<"感謝光臨!"<<endl;
}
else if(money<0)
{
cout<<"快把"<<-money<<"加隆交來!"<<endl;
goto change;
}else
{
cout<<"找你"<<money<<"加隆"<<endl;
if(money>=100)
{
cout<<"100加隆"<<money/100<<"枚"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"50加隆"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"10加隆"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>0)
{
cout<<"1加隆"<<money<<"枚"<<endl;
}
}
cout<<endl<<"下次再來"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪振庭
時間:
2015-4-11 10:59
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re2:
int p,q,sum=0,option,pay,money;
string name[7]={"速效跳課糖 ","米你毛毛球 ","無頭帽 ","金斯雀奶油蛋糕","攜帶型沼澤 ","假魔杖 ","伸縮耳 "};
int price[7]={90,80,74,3,80,1,4};
int qty[7]={0,0,0,0,0,0,0};
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;
cout<<"[加隆任務]消費100加隆送假魔丈*30"<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
goto checkout;
else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
if(q<=0)
{
cout<<"錯誤!"<<endl;
goto re;
}
sum+=price[p-1]*q;
qty[p-1]+=q;
}
else
{
cout<<"錯誤!"<<endl;
}
goto re;
checkout:
cout<<endl<<"[魔法清單]"<<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;
if(sum >= 100)
{
cout<<"你消費"<<sum<<"加隆,符合滿100加隆的任務"<<endl<<endl;
cout<<"假魔丈*30是你的了!"<<endl;
}
cout<<"總共"<<sum<<"加隆!"<<endl<<endl;
cout<<"1-正確無誤 2-重新選購 ";
cin>>option;
if(option==1)
{
goto change;
}
else
{
system("cls");
goto re2;
}
change:
cout<<endl<<"請付帳: ";
cin>>pay;
money=pay-sum;
if(money==0)
{
cout<<"感謝光臨!"<<endl;
}
else if(money<0)
{
cout<<"快把"<<-money<<"加隆交來!"<<endl;
goto change;
}else
{
cout<<"找你"<<money<<"加隆"<<endl;
if(money>=100)
{
cout<<"100加隆"<<money/100<<"枚"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"50加隆"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"10加隆"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>0)
{
cout<<"1加隆"<<money<<"枚"<<endl;
}
}
cout<<endl<<"下次再來"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
梁和雋
時間:
2015-4-11 11:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re2:
int p,q,sum=0,option,pay,money;
string name[5]={"CAD ","黑卡蒂II","冰果 ","超電磁炮 ","贄殿遮那 "};
int price[5]={40000,245000,200,40000,12500};
int qty[5]={0,0,0,0,0};
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表(一律以日幣計)]"<<endl;
for(int i=0; i<5; i++)
{
cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
}
cout<<"(6)結帳"<<endl<<endl;
cout<<"動漫促銷->滿100元送對老師專用核彈乙枚"<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==6)
goto checkout;
else if(p>=1 && p<=5)
{
cout<<"數量: ";
cin>>q;
if(q<=0)
{
cout<<"輸入錯誤!"<<endl;
goto re;
}
sum+=price[p-1]*q;
qty[p-1]+=q;
}
else
{
cout<<"輸入錯誤!"<<endl;
}
goto re;
checkout:
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<<"總共"<<sum<<"元!"<<endl<<endl;
cout<<"1-正確無誤 2-重新選購 ";
cin>>option;
if(option==1)
{
goto change;
}
else
{
system("cls");
goto re2;
}
change:
cout<<endl<<"請付帳: ";
cin>>pay;
money=pay-sum;
if(money==0)
{
cout<<"錢剛好!"<<endl<<endl;
}
else if(money<0)
{
cout<<"錢不夠!還差"<<-money<<"元!"<<endl;
goto change;
}else
{
cout<<"找您"<<money<<"元!"<<endl;
if(money>=1000)
{
cout<<"一千元鈔票"<<money/1000<<"張"<<endl;
money%=1000;
}
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money%=500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money%=10;
}
if(money>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money%=5;
}
if(money>0)
{
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
cout<<endl<<"銘謝惠顧!"<<endl;
cout<<"滿100元送<對老師專用核彈乙枚>"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李大全
時間:
2015-4-11 11:09
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re2:
int p,q,sum=0,option,pay,money;
string name[7]={"1","2","3","4","5","6","7"};
int price[7]={90,80,74,3,80,1,4};
int qty[7]={0,0,0,0,0,0,0};
cout<<"****123456789////////////法寶店****"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
for(int i=0; i<7; i++)
{
cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
}
cout<<"(8)結帳"<<endl<<endl;
cout<<"[100......元.....任務]消費100.....元.....送12.*30"<<endl;
re:
cout<<"請輸入商品代碼: ";
cin>>p;
if(p==8)
goto checkout;
else if(p>=1 && p<=7)
{
cout<<"數量: ";
cin>>q;
if(q<=0)
{
cout<<"錯誤!"<<endl;
goto re;
}
sum+=price[p-1]*q;
qty[p-1]+=q;
}
else
{
cout<<"錯誤!"<<endl;
}
goto re;
checkout:
cout<<endl<<"[........清單]"<<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;
if(sum >= 100)
{
cout<<"你消費"<<sum<<".......元,符合滿100......的任務"<<endl<<endl;
cout<<"12.*30是你的了!"<<endl;
}
cout<<"總共"<<sum<<"元..........!"<<endl<<endl;
cout<<"1-正確誤................... 2-重選購................. ";
cin>>option;
if(option==1)
{
goto change;
}
else
{
system("cls");
goto re2;
}
change:
cout<<endl<<"請付帳: ";
cin>>pay;
money=pay-sum;
if(money==0)
{
cout<<"感謝光臨!"<<endl;
}
else if(money<0)
{
cout<<"快把"<<-money<<"錢拿來..................!"<<endl;
goto change;
}else
{
cout<<"找你"<<money<<"元喔!啾咪!喔!啾咪元喔!"<<endl;
if(money>=100)
{
cout<<"100"<<money/100<<"..........................元"<<endl;
money%=100;
}
if(money>=50)
{
cout<<"50"<<money/50<<"........................元"<<endl;
money%=50;
}
if(money>=10)
{
cout<<"10"<<money/10<<".......................元"<<endl;
money%=10;
}
if(money>0)
{
cout<<"1"<<money<<".............................元"<<endl;
}
}
cout<<endl<<"11111再來吧"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
謝瀞儀
時間:
2015-4-11 12:27
本帖最後由 謝瀞儀 於 2015-4-21 19:41 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re2:
int thing, number,sum=0,option,pay,price,money1;
string name[21]={"V家七宗罪系列(包含序號2~9)",
"湯匙(齒輪) ",
"酒杯 ",
"劍 ",
"金鑰匙 ",
"人偶 ",
"四面鏡 ",
"禍世之剪 ",
"上了發條的搖籃曲 ",
"白癡藥水 ",
"生鏽的齒輪人偶 ",
"受詛咒之雙刃(附皮革套) ",
"跳針的古老大鐘 ",
"失憶藥丸 ",
"座敷童子的靈棺 ",
"淌血的附喪神人偶 ",
"會咬人的蜘蛛玩偶 ",
"梅杜莎的頭顱 ",
"巫婆熬藥的大鍋 ",
"活生生殭屍殺人魔/吸血鬼 "};
int money[21]={1200,70,80,80,100,120,150,100,350,70,80,20,1300,130,700,130,120,500,1000,10000};
int qty[21]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
cout<<"XXX崩壞/中二玩具精品店XXX"<<endl;
cout<<"這裡的壞掉商品包山包海,應有盡有,等你來搜刮!"<<endl;
cout<<"本店絕對沒有惡意哄抬價格,也絕對沒有低價購入,高價賣出的不良嗜好,敬請安心"<<endl;
cout<<"對於購買商品的問題,出事本店一概不負責"<<endl;
cout<<"--------------------------------------------------------------------------"<<endl;
cout<<endl<<endl<<"[促銷方案]"<<endl;
cout<<"消費滿500萬送半張衛生紙乙份"<<endl
<<"消費滿700萬送一元折價卷乙本(每本50張,不得於當次使用,一次來店限用一張)"<<endl
<<"消費滿1000萬送食人菜瓜布乙份+夏語遙代言?將碗盤洗的超乾淨牌洗碗精?乙份"<<endl
<<"加一百萬升級食魔菜瓜布乙份+夏語遙代言?將魔物洗的超乾淨牌洗碗精?乙份"<<endl
<<"消費滿1億送食魔菜瓜布乙份+夏語遙代言?將魔物洗的超乾淨牌洗碗精?乙份"<<endl
<<endl;
int i=0;
while(i<20)
{
cout<<"("<<i+1<<")"<<name[i]<<"\t"<<money[i]<<"萬元"<<endl;
i++;
}
cout<<"(21)結帳"<<endl;
re:
cout<<"請輸入商品代號: "<<endl;
cin>>thing;
if(thing==21)
{
goto checkout;
}
else if(thing>0 && thing<21)
{
cout<<"數量: "<<endl;
cin>>number;
if(number<=0)
{
cout<<"奧客去死辣!本店將會詛咒你的餘生(甩門)"<<endl;
goto re;
}
sum+=money[thing-1]*number;
qty[thing-1]+=number;
}
else
{
cout<<"奧客去死辣!本店將會詛咒你的餘生(甩門)"<<endl;
}
goto re;
checkout:
cout<<endl<<"中二精品購物清單"<<"\a"<<endl;
cout<<"------------------------------"<<"\n";
for(int i=0;i<21;i++)
{
if(qty[i]!=0)
{
cout<<name[i]<<"\t"<<money[i]<<"元 * "<<qty[i]<<"個"<<endl;
}
}
cout<<"------------------------------"<<"\n";
if(sum==0)
{
cout<<"0元"<<endl;
}
else
{
cout<<"共"<<sum<<"萬元"<<endl;
if(sum>500 && sum<700)
{
cout<<"[促銷方案] 滿500萬送半張衛生紙乙份"<<endl<<endl;
}
else if(sum>700 && sum<1000)
{
cout<<"[促銷方案] 滿700萬送一元折價卷乙本"
"(每本50張,不得於當次使用,一次來店限用一張)";
}
else if(sum>1000 && sum<10000)
{
cout<<"[促銷方案] 滿1000萬送食人菜瓜布乙份"
"+夏語遙代言?將碗盤洗的超乾淨牌洗碗精?乙份";
cout<<"是否要加100萬升級食魔菜瓜布乙份"
"+夏語遙代言?將魔物洗的超乾淨牌洗碗精?乙份"<<endl;
cout<<"1-是 2-否 ";
cin>>option;
if(option==1)
{
sum+=100;
}
else
{
goto choice;
}
}
else if(sum>=10000)
{
cout<<"[促銷方案] 滿1億送食魔菜瓜布乙份"
"+夏語遙代言?將魔物洗的超乾淨牌洗碗精?乙份"<<endl;
}
choice:
cout<<"1-正確 2-錯誤,重選"<<endl;
cin>>option;
if(option==1)
{
goto change;
}
else
{
system("cls");
goto re2;
}
change:
cout<<"請付錢(萬元) "<<endl;
cin>>pay;
money1=pay-sum;
if(money1==0)
{
cout<<"錢嘟嘟好"<<endl;
}
else if(money1<0)
{
cout<<"錢不夠,老子詛咒你永世不得超生"<<endl;
goto change;
}
else
{
cout<<"找您"<<money1<<"萬元"<<endl;
if(money1>=2000)
{
cout<<"二千元鈔票"<<money1/2000<<"萬將"<<endl;
money1%=2000;
}
if(money1>=1000)
{
cout<<"一千元鈔票"<<money1/1000<<"萬將"<<endl;
money1%=1000;
}
if(money1>=500)
{
cout<<"五百元鈔票"<<money1/500<<"萬將"<<endl;
money1%=500;
}
if(money1>=200)
{
cout<<"二百元鈔票"<<money1/200<<"萬將"<<endl;
money1%=200;
}
if(money1>=100)
{
cout<<"一百元鈔票"<<money1/100<<"萬將"<<endl;
money1%=100;
}
if(money1>=50)
{
cout<<"五十元硬幣"<<money1/50<<"萬個"<<endl;
money1%=50;
} if(money1>=20)
{
cout<<"二十元硬幣"<<money1/20<<"萬個"<<endl;
money1%=20;
} if(money1>=10)
{
cout<<"十元硬幣"<<money1/10<<"萬個"<<endl;
money1%=10;
}
if(money1>=5)
{
cout<<"五元硬幣"<<money1/5<<"萬個"<<endl;
money1%=5;
}
if(money1>0)
{
cout<<"一元硬幣"<<money1<<"萬個"<<endl;
}
cout<<endl<<"中二精品玩具店謝謝您的惠顧"<<endl
<<"再重申一次,對於購買商品的問題,"
<<"出事本店一概不負責,感謝您的光臨!!"<<endl;
}
}
system("pause");
return 0;
}
複製代碼
作者:
吳柏融
時間:
2023-1-28 20:29
1234567890-
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2