標題:
智慧找零系統
[打印本頁]
作者:
tonyh
時間:
2013-11-30 16:20
標題:
智慧找零系統
本帖最後由 tonyh 於 2013-11-30 17:22 編輯
設計一智慧找零系統, 使用者可輸入商品價格與客人付了多少錢, 電腦回應需找多少錢, 並顯示細節.
譬如: 若有一230元的商品, 客人付了1000元, 則電腦回應
總共需找客人770元
500元鈔票1張
100元鈔票2張
50元硬幣1枚
10元硬幣2枚
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price, pay, money;
cout<<"*** 智慧找零系統 v1.0 ***"<<endl<<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/1<<"枚"<<endl;
money=money%1;
}
system("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2013-11-30 16:43
#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;
}
system("pause");
return 0;
}
複製代碼
作者:
施伯叡
時間:
2013-11-30 17:12
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int price,pay,money;
cout<<"***智慧找零系統***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"請輸入客人付的錢: ";
cin>>pay;
money=pay-price;
cout<<"你應該找給客人"<<money<<"元"<<endl;
if(money>=500)
{
cout<<"五百元鈔票"<<money/500<<"張"<<endl;
money=money%500;
}
if(money>=100)
{
cout<<"一百元鈔票"<<money/100<<"張"<<endl;
money=money%100;
}
if(money>=50)
{
cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
money=money%50;
}
if(money>=10)
{
cout<<"十元硬幣"<<money/10<<"枚"<<endl;
money=money%10;
}
if(money>=1)
{
cout<<"一元硬幣"<<money/1<<"枚"<<endl;
money=money%1;
}
system("pause");
return 0;
}
複製代碼
作者:
張峻瑋
時間:
2013-11-30 17:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price,pay,money;
cout<<"***智慧找零系統 v1.0***"<<endl<<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/1<<"枚"<<endl;
money=money%1;
}
system("pause");
return 0;
}
複製代碼
作者:
張郁庭
時間:
2013-11-30 17:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price,pay,money;
cout<<"****智慧找零系統****"<<endl;
cout<<"請輸入商品的價格:"<<endl;
cin>>price;
cout<<"請輸入客人付了多少錢:"<<endl;
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/1<<"枚"<<endl;
money=money%1;
}
system ("pause");
return 0;
}
複製代碼
作者:
周雍程
時間:
2013-11-30 17:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price, pay, money;
cout<<"*** 智慧找零系統 ***"<<endl<<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/1<<"枚"<<endl;
money=money%1;
}
system("pause");
return 0;
}
複製代碼
作者:
張彥承
時間:
2013-11-30 17:19
#include<iostream>
#include<cstdlib>
using namespace std;
int main ()
{
int total,cm,givingmoney;
cout<<"***intelligent money-giving machine***"<<endl;
cout<<"the purchase cost:"<<endl;
cin>>total;
cout<<"customers shell out:"<<endl;
cin>>cm;
givingmoney=cm-total;
cout<<"you need to give: "<<givingmoney<<endl;
if(givingmoney>=500)
{
cout<<"500 dollar bills: "<<givingmoney/500<<" piece"<<endl;
givingmoney=givingmoney%500;
} if(givingmoney>=100)
{
cout<<"100 dollar bills: "<<givingmoney/100<<" piece"<<endl;
givingmoney=givingmoney%100;
} if(givingmoney>=50)
{
cout<<"50 dollar coin: "<<givingmoney/50<<" cookie"<<endl;
givingmoney=givingmoney%50;
} if(givingmoney>=10)
{
cout<<"10 dollar coin: "<<givingmoney/10<<" cookie"<<endl;
givingmoney=givingmoney%10;
}if(givingmoney>=5)
{
cout<<"5 dollar coin: "<<givingmoney/5<<" cookie"<<endl;
givingmoney=givingmoney%5;
}if(givingmoney>=1)
{
cout<<"1 dollar coin: "<<givingmoney/1<<" cookie"<<endl;
givingmoney=givingmoney%1;
}
system("pause");
return 0;
}
複製代碼
作者:
張郁偵
時間:
2013-11-30 17:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int total,pay,money;
cout<<"****智慧找零系統****"<<endl;
cout<<"請輸入商品價格: ";
cin>>total;
cout<<"請輸入你所要付的金額: ";
cin>>pay;
money=pay-total;
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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2