標題:
[作業] 購物系統 (四)
[打印本頁]
作者:
tonyh
時間:
2013-7-20 15:35
標題:
[作業] 購物系統 (四)
新增 "1-正確無誤 2-重新選購" 的選單
讓使用者在準備結帳時還能反悔, 譬如錢帶不夠.
作者:
黃崇維
時間:
2013-7-20 16:52
本帖最後由 黃崇維 於 2013-7-20 20:30 編輯
#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;
cout<<"1-正確無誤 2-重新選購"<<endl;
cout<<"請輸入你的決定"<<endl;
cin>>a;
if(a==1)
cout<<"請交出你的錢!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
劉泳鱔
時間:
2013-7-21 21:26
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"憤怒鳥 ","狼牙棒 ","冷氣","殺手/一個人","不求人抓抓背快樂抓抓小手","劉博士用過的毛巾","踩劉博士走過的路"};
int price[]={};
int qty[]={0,0,0,0,0,0,0};
int p, q, money, pay, sum=0, a;
cout<<"劉博士之甚麼都賣店"<<endl<<endl;
cout<<"[只有聰明人才看的到的價目表]"<<endl;
cout<<"(1)憤怒鳥\t\t300元/隻"<<endl;
cout<<"(2)狼牙棒\t\t799元"<<endl;
cout<<"(3)冷氣\t\t80000元"<<endl;
cout<<"(4)殺手/一個人\t\t200元"<<endl;
cout<<"(5)不求人抓抓背快樂抓抓小手\t1399元"<<endl;
cout<<"(6)劉博士用過的毛巾/條\t100000元"<<endl;
cout<<"(7)踩劉博士走過的路/一步\t3000元"<<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;
cout<<"1-正確無誤 2-重新選購"<<endl;
cout<<"請輸入你要的"<<endl;
cin>>a;
if(a==1)
cout<<"Please摳摳拿來!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林以諾
時間:
2013-7-22 13:15
#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,a;
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<<"1.前去結帳 2-重新選購"<<endl;
cin>>a;
if(a==1)
{
goto checkout2;
}
else if(a==2)
{
goto start;
}
else
{
cout<<"什麼年紀了還會輸入錯誤!!"<<endl;
}
checkout2:
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<<"元"<<endl;
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-22 21:08
本帖最後由 張瀚仁 於 2013-7-27 15:39 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
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,e;
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 re;
}
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;
cout<<"1正確無誤2重新選購"<<endl;
cin>>e;
if(e==1)
{
goto good;
}else if(e==2)
{
goto re;
}else
{
cout<<"輸入錯誤"<<endl;
}
good:
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-25 01:33
本帖最後由 劉得旗 於 2013-7-25 01:35 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
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,e;
cout<<"@@@死亡屋@@@"<<endl;
cout<<"商品價目表"<<endl;
cout<<"(1)黃金制棺材\t\t1200元"<<endl;
cout<<"(2)檜木製棺材\t\t1250元"<<endl;
cout<<"(3)玻璃棺材\t\t850元"<<endl;
cout<<"(4)青花瓷骨灰盆\t\t125元"<<endl;
cout<<"(5)飲料罐骨灰盆\t\t10元"<<endl;
cout<<"(6)可口可樂玻璃瓶骨灰盆 25元"<<endl;
cout<<"消費滿1500送去死!![限量!]"<<endl;
cout<<"選購完時代號都輸入0即可進入死亡結帳頁"<<endl;
start:
cout<<"請輸入死亡商品代號:"<<endl;
cin>>a;
if(a==0)
{
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;
cout<<"1正確無誤2重新選購"<<endl;
cin>>e;
if(e==1)
{
goto good;
}else if(e==2)
{
goto re;
}else
{
cout<<"輸入錯誤!腦殘!"<<endl;
}
good:
if(sum>=1500)
{
cout<<"由於消費滿1500,送妳去死!!"<<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-26 16:14
本帖最後由 長逸 於 2013-7-27 13:59 編輯
1
複製代碼
作者:
長逸
時間:
2013-7-26 16:45
本帖最後由 長逸 於 2013-7-27 14:05 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
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,e;
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送提一隻!!(限量 市價1001000元)"<<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;
cout<<"1正確無誤2重新選購"<<endl;
cin>>e;
if(e==1)
{
goto good;
}else if(e==2)
{
goto re;
}else
{
cout<<"輸入錯誤"<<endl;
}
good:
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-27 11:25
#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,g,pay,money,chose;
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;
back:
cout<<"(1)繼續(2)重新選購"<<endl;
cin>>chose;
if(chose==1)
{
goto go;
}else if(chose==2)
{
goto start;
}else
{
cout<<"輸入錯誤";
goto back;
}
go:
cout<<"請輸入付了多少錢: ";
cin>>pay;
money=pay-sum;
if(money==0)
{
cout<<"錢剛剛好! 請慢走!"<<endl;
}
if(money<0)
{
cout<<"錢不夠! 還欠"<<-money<<endl;
}
if(money>0)
{
cout<<"總共需要找客人"<<money<<"元"<<endl;
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-27 13:17
本帖最後由 黃柏維 於 2013-7-27 14:19 編輯
#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,a;
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;
cout<<"1-正確無誤 2-重新選購"<<endl;
cin>> a;
if(a==1)
{
cout<<"請輸入您付的錢: "<<endl;
cin>>pay;
cout<<"找您"<<pay-p<<"元"<<endl;
}
else if(a==2)
{
goto start;
}
else
{
cout<<"輸入錯誤"<<endl;
goto start;
}
money=pay-sum;
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-27 14:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
string name[]={"阿姆姆","艾希","安妮","蓋倫","維爾賽","佛德提克"}; {:3_44:} {:3_41:} :)
int qty[]={0,0,0,0,0,0};
int price[]={1240,136,2584,251,987,654};
int a,b,sum=0,pay,money,e;
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送提一隻!!(限量 市價1001000元)"<<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;
cout<<"1正確無誤2重新選購"<<endl;
cin>>e;
if(e==1)
{
goto good;
}else if(e==2)
{
goto re;
}else
{
cout<<"輸入錯誤"<<endl;
}
good:
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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2