標題:
[作業] 智慧找零系統進階
[打印本頁]
作者:
tonyh
時間:
2013-5-25 15:06
標題:
[作業] 智慧找零系統進階
設計一個更聰明的智慧找零系統, 包括客人付的錢不足, 剛好, 或
任何
可能發生的其他情況.
作者:
黃崇維
時間:
2013-5-25 16:27
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price, pay, money;
cout<<"***崇維發明的優秀找零系統***"<<endl;
cout<<"請輸入商品價格:";
cin>>price;
cout<<"請輸入客人付了多少錢: ";
cin>>pay;
money=pay-price;
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-5-25 17:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price, pay, money;
cout<<"***搶錢找零系統***"<<endl;
cout<<"請輸入商品價錢:";
cin>>price;
cout<<"請輸入客人付多少錢:";
cin>>pay;
money=pay-price;
if(pay<price)
{
cout<<"回你家拿錢!還少"<<price-pay<<"元啦!!!"<<endl;
}
if(price==pay)
{
cout<<"不錯!!剛剛好!!!"<<endl;
}
if(pay>price)
{ 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-5-26 18:42
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price, pay, money;
cout<<"*****劉泳鱔博士知超優秀找零系統*****"<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"請輸入客人付了多少錢: ";
cin>>pay;
money=pay-price;
cout<<"總共需找客人"<<money<<"元"<<endl;
if(money<0)
{
cout<<"ㄟㄟ ㄟ!吃完飯不用付錢喔:O"<<endl;
}
if(money==0)
{
cout<<"錢剛剛好!可以滾了"<<endl;
}
if(money>0)
{
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<<"枚"<<endl;
}
}
system("pause");
return 0;
}
複製代碼
作者:
張瀚仁
時間:
2013-5-26 22:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price, pay, money;
cout<<"***智慧找零系統***"<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"請輸入客人付了多少錢: ";
cin>>pay;
money=pay-price;
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<<"枚"<<endl;
}
if(price>pay)
{
cout<<"客人,你的錢不夠,留下來洗碗吧!"<<endl;
}else
if(pay==price)
{
cout<<"錢剛好!"<<endl;
} else
if(price>2000 && pay>price)
{
cout<<"沒錢還買這麼貴的東西,你打算怎麼付?"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
鎧言
時間:
2013-5-31 21:45
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price, pay, money;
cout<<"***鎧言發明的超智慧找零系統***"<<endl;
cout<<"請輸入商品價格:";
cin>>price;
cout<<"請輸入客人付了多少錢: ";
cin>>pay;
money=pay-price;
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-6-1 13:23
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price,pay,money;
cout<<"***智慧找零系統***"<<endl;
cout<<"請輸入商品價錢: ";
cin>>price;
cout<<"請輸入客人付了多少錢: ";
cin>>pay;
money=pay-price;
if(money==0)
{
cout<<"剛剛好!謝謝你"<<endl;
}
else if(money>=0)
{
cout<<"謝謝!找你 "<<money<<"元"<<endl;
}
else if(money<=-1)
{
cout<<"對不起!還差 "<<money*-1<<"元"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
許逸群
時間:
2013-6-10 20:52
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price, pay, money;
cout<<"***逸群智慧找零系統***"<<endl;
cout<<"請輸入商品價格:";
cin>>price;
cout<<"輸入客人付了多少錢: ";
cin>>pay;
money=pay-price;
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://istak.org.tw/seed/)
Powered by Discuz! 7.2