標題:
智慧找零系統 (一)
[打印本頁]
作者:
葉桔良
時間:
2022-4-9 15:52
標題:
智慧找零系統 (一)
本帖最後由 葉桔良 於 2022-4-9 17:29 編輯
設計一智慧找零系統, 使用者可輸入商品價格與客人付了多少錢, 電腦回應需找多少錢, 並顯示細節.
譬如: 若有一230元的商品, 客人付了1000元, 則電腦回應
總共需找客人770元
500元鈔票1張
100元鈔票2張
50元硬幣1枚
10元硬幣2枚
作者:
葉桔良
時間:
2022-4-9 15:52
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
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>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
郭閎宇
時間:
2022-4-9 16:55
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
re:
int price=0,cost=0,money=0;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格:";
cin>>price;
cout<<"客人付了多少錢:";
cin>>cost;
cout<<endl<<endl;
money=cost-price;
cout<<"須找客人"<<money<<endl<<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>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money = money%5;
}
if(money>=1)
{
cout<<"一元硬幣"<<money/1<<"枚"<<endl;
money = money%1;
}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
許浩浩
時間:
2022-4-9 16:55
本帖最後由 許浩浩 於 2022-4-9 17:31 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a, b, c;
cout<<"***智慧找零系統***"<<endl<<endl;
cout<<"請輸入商品價格:"<<endl;
cin>>a;
cout<<"客人付了多少錢:";
cin>>b;
cout<<endl;
c=b-a;
cout<<"需找客人"<<c<<"元"<<endl;
if(c>500){
cout<<"五百元鈔票"<<c/500<<"張"<<endl;
c=c%500}
if(c>100){
cout<<"一百元鈔票"<<c/100<<"張"<<endl;
c=c%100}
if(c>50){
cout<<"五十元硬幣"<<c/500<<"枚"<<endl;
c=c%50}
if(c>10){
cout<<"十元硬幣"<<c/10<<"枚"<<endl;
c=c%10}
if(c>1){
cout<<"一元硬幣"<<c/1<<"枚"<<endl;
c=c%1}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
黃昱琁
時間:
2022-4-9 16:56
本帖最後由 黃昱琁 於 2022-4-9 17:10 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int p=0,c=0,m=0;
cout<<"***智慧找零系統***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>p;
cout<<"客人付了多少錢: ";
cin>>c;
m=c-p;
cout<<"須找客人"<<m<<"元"<<endl<<endl;
if(m>=500)
cout<<"五百元鈔票"<<m/500<<"張"<<endl;
m=m%500;
if(m>=100)
cout<<"一百元鈔票"<<m/100<<"張"<<endl;
m=m%100;
if(m>=50)
cout<<"五十元硬幣"<<m/50<<"枚"<<endl;
m=m%50;
if(m>=10)
cout<<"十元硬幣"<<m/10<<"枚"<<endl;
m=m%10;
if(m>=1)
cout<<"一元硬幣"<<m/1<<"枚"<<endl;
m=m%1;
system("pause");
return 0;
}
複製代碼
作者:
錢冠叡
時間:
2022-4-9 16:59
本帖最後由 錢冠叡 於 2022-4-9 17:30 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
//re:
int price=0,cost=0,money=0;
cout<<"*** 智慧找零系統 ***"<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>cost;
cout<<endl;
money=cost-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;
}
//goto re;
system("pause");
return 0;
}
複製代碼
作者:
王競儀
時間:
2022-4-9 17:00
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price=0,cost=0,money=0;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>cost;
cout<<endl;
money=cost-price;
cout<<"需找客人"<<money<<"元"<<endl;
cout<<endl;
if(money>=1000)
{
cout<<"一千元鈔票"<<money/1000<<"張"<<endl;
money=money%1000;
}
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>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money=money%5;
}
if(money>=1)
{
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
連翊恩
時間:
2022-4-9 17:00
本帖最後由 連翊恩 於 2022-4-9 17:13 編輯
#include<cstdlib>
using namespace std;
int main()
{
int a=0,b=0,money=0;
cout<<" *** 智慧找零系統 *** "<<endl;
cout<<"商品價格: ";
cin>>a;
cout<<"客人付了多少錢: ";
cin>>b;
cout<<endl;
money = b-a;
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;
}
複製代碼
作者:
侯宣仲
時間:
2022-4-9 17:01
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a=0,b=0,c=0,;
//re:
cout<<" ***智慧找靈系統***"<<endl<<endl;
cout<<"請輸入商品價格 : ";
cin>>a;
cout<<"客人付了多少錢 :";
cin>>b;
cout<<endl;
c=b-a;
cout<<"需找客人"<<c<<"元"<<endl<<endl;
if(c>=500){
cout<<"五百元鈔票"<<c/500<<"張"<<endl;
c=c%500;
}
if(c>=100){
cout<<"一百元鈔票"<<c/100<<"張"<<endl;
c=c%100;
}
if(c>=50){
cout<<"五十元"<<c/50<<"枚"<<endl;
c=c%50;
}
if(c>=10){
cout<<"十元"<<c/10<<"枚"<<endl;
c=c%10;
}
if(c>=1){
cout<<"一元"<<c/1<<"枚"<<endl;
}
//goto re;
system("pause");
return 0;
}
複製代碼
作者:
侯宥安
時間:
2022-4-9 17:01
本帖最後由 侯宥安 於 2022-4-9 17:21 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a=0,b=0,c=0,;
//re:
cout<<" ***智慧找靈系統***"<<endl<<endl;
cout<<"請輸入商品價格 : ";
cin>>a;
cout<<"客人付了多少錢 :";
cin>>b;
cout<<endl;
c=b-a;
cout<<"需找客人"<<c<<"元"<<endl<<endl;
if(c>=500){
cout<<"五百元鈔票"<<c/500<<"張"<<endl;
c=c%500;
}
if(c>=100){
cout<<"一百元鈔票"<<c/100<<"張"<<endl;
c=c%100;
}
if(c>=50){
cout<<"五十元"<<c/50<<"枚"<<endl;
c=c%50;
}
if(c>=10){
cout<<"十元"<<c/10<<"枚"<<endl;
c=c%10;
}
if(c>=1){
cout<<"一元"<<c/1<<"枚"<<endl;
}
//goto re;
system("pause");
return 0;
}
作者:
李彥錡
時間:
2022-4-9 17:03
本帖最後由 李彥錡 於 2022-4-9 17:31 編輯
[code]#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price=0,cost=0,money=0;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>cost;
cout<<endl;
money=cost-price;
cout<<"需找客人: "<<money<<"元"<<endl<<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>=5){
cout<<"五元鈔票"<<money/5<<"枚"<<endl;
money=money%5;
}
if(money>=1){
cout<<"五元鈔票"<<money/1<<"枚"<<endl;
money=money%1;
}
system("pause");
return 0;
}
複製代碼
[/code]
作者:
謝閔丞
時間:
2022-4-9 17:06
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a,b,c;
cout<<"***智慧找零系統***"<<endl;
cout<<"請輸入商品價格:";
cin>>a;
cout<<"客人給的錢:";
cin>>b;
c=b-a;
cout<<"需給客人"<<c<<"元"<<endl;
if(c>=500){
cout<<"五百元鈔票"<<c/500<<"張"<< endl;
c=c%500;
}
if(c>=100){
cout<<"一百元鈔票"<<c/100<<"張"<< endl;
c=c%100;
}
if(c>=50){
cout<<"五十元硬幣"<<c/50<<"枚"<< endl;
c=c%50;
}
if(c>=10){
cout<<"十元硬幣"<<c/10<<"枚"<< endl;
c=c%10;
}
if(c>=1){
cout<<"一元硬幣"<<c<<"枚"<< endl;
}
system("pause");
return 0;
}
複製代碼
作者:
許博鈞
時間:
2022-4-9 17:08
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price=0,cout=0,money=0;
cout<<"***智慧找靈系統***"<<endl<<endl;
cout<<"請輸入商品價格:";
cout<<"客人付了多少錢?:";
cin>>cout;
cout<<endl;
money=cout-price
cout<<"需找客人"<<money<<"元"<<endl <<endl;
if (money>500){
cout<<"五百元鈔票"<< money/500<<"張";
money=money%500;
cout<<money;
}
if (money>100){
cout<<"一百元鈔票"<< money/100<<"張";
money=money%100;
cout<<money;
}
if (money>50){
cout<<"五十元硬幣"<< money/50<<"枚";
money=money%50;
cout<<money;
}
if (money>10){
cout<<"十元硬幣"<< money/10<<"枚";
money=money%10;
cout<<money;
}
system("pause");
return 0;
}
複製代碼
作者:
石皓云
時間:
2022-4-9 17:11
本帖最後由 石皓云 於 2022-4-9 17:33 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a,b,c;
cout<<"***智慧找零系統***"<<endl<<endl;
cout<<"請輸入商品價格:";
cin>>a;
cout<<"客人付了多少錢:";
cin>>b;
cout<<endl;
c=b-a;
cout<<"需找客人"<<c<<"元"<<endl;
if(c>=500){
cout<<"五百元鈔票"<<c/500<<"張"<<endl;
c %= 500;
}
if(c>=100){
cout<<"一百元鈔票"<<c/100<<"張"<<endl;
c %= 100;
}
if(c>=50) {
cout<<"五十元硬幣"<<c/50<<"枚"<<endl;
c %= 50;
}
if(c>=10){
cout<<"十元硬幣"<<c/10<<"枚"<<endl;
c %= 10;
}
if(c>=1)
cout<<"一元硬幣"<<c<<"枚"<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
孫文康
時間:
2022-4-9 17:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price,coust,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格:";
cin>>price;
cout<<"客人付了多少錢:";
cin>>coust;
cout<<"需找客人"<<coust-price<<"元";
money=coust-price;
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/50<<"玫" <<endl;
money%=5;
}
if(money>1){
cout<<"一元硬幣"<<money/1<<"玫" <<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
侯宥安
時間:
2022-4-9 17:22
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a=0,b=0,c=0,;
//re:
cout<<" ***智慧找靈系統***"<<endl<<endl;
cout<<"請輸入商品價格 : ";
cin>>a;
cout<<"客人付了多少錢 :";
cin>>b;
cout<<endl;
c=b-a;
cout<<"需找客人"<<c<<"元"<<endl<<endl;
if(c>=500){
cout<<"五百元鈔票"<<c/500<<"張"<<endl;
c=c%500;
}
if(c>=100){
cout<<"一百元鈔票"<<c/100<<"張"<<endl;
c=c%100;
}
if(c>=50){
cout<<"五十元"<<c/50<<"枚"<<endl;
c=c%50;
}
if(c>=10){
cout<<"十元"<<c/10<<"枚"<<endl;
c=c%10;
}
if(c>=1){
cout<<"一元"<<c/1<<"枚"<<endl;
}
//goto re;
system("pause");
return 0;
}
複製代碼
作者:
張駿霖
時間:
2022-4-9 17:30
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
re:
int price=0,cost=0,money=0;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格:";
cin>>price;
cout<<"客人付了多少錢:";
cin>>cost;
cout<<endl<<endl;
money=cost-price;
cout<<"須找客人"<<money<<endl<<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>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money = money%5;
}
if(money>=1)
{
cout<<"一元硬幣"<<money/1<<"枚"<<endl;
money = money%1;
}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
侯宣仲
時間:
2022-4-9 17:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a=0,b=0,c=0,;
//re:
cout<<" ***智慧找靈系統***"<<endl<<endl;
cout<<"請輸入商品價格 : ";
cin>>a;
cout<<"客人付了多少錢 :";
cin>>b;
cout<<endl;
c=b-a;
cout<<"需找客人"<<c<<"元"<<endl<<endl;
if(c>=500){
cout<<"五百元鈔票"<<c/500<<"張"<<endl;
c=c%500;
}
if(c>=100){
cout<<"一百元鈔票"<<c/100<<"張"<<endl;
c=c%100;
}
if(c>=50){
cout<<"五十元"<<c/50<<"枚"<<endl;
c=c%50;
}
if(c>=10){
cout<<"十元"<<c/10<<"枚"<<endl;
c=c%10;
}
if(c>=1){
cout<<"一元"<<c/1<<"枚"<<endl;
}
//goto re;
system("pause");
return 0;
}
複製代碼
作者:
侯宣任
時間:
2022-4-9 17:31
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
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>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
王競儀
時間:
2022-4-9 17:31
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int price=0,cost=0,money=0;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>cost;
cout<<endl;
money=cost-price;
cout<<"需找客人"<<money<<"元"<<endl;
cout<<endl;
if(money>=1000)
{
cout<<"一千元鈔票"<<money/1000<<"張"<<endl;
money=money%1000;
}
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>=5)
{
cout<<"五元硬幣"<<money/5<<"枚"<<endl;
money=money%5;
}
if(money>=1)
{
cout<<"一元硬幣"<<money<<"枚"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
侯宥安
時間:
2022-4-10 17:13
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
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>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
侯宥安
時間:
2022-4-10 17:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int price,pay,money;
cout<<"*** 智慧找零系統 ***"<<endl<<endl;
cout<<"請輸入商品價格: ";
cin>>price;
cout<<"客人付了多少錢: ";
cin>>pay;
money=pay-price;
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>0)
cout<<"一元硬幣"<<money<<"枚"<<endl;
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2