编写一个程序,用c++完成atms的基本事务.它会根据某个东西的使用次数来减少它的数量

write a program that will do a basic transaction of atms in c++. It will decrease the amount of something by how many times it is used

本文关键字:一个 程序 atms 完成 c++ 事务      更新时间:2023-10-16

我有一个部分要求您输入金额,它将输出它必须是什么类型的钞票。(例如,对于$220,输出将是2$100和2$10。)

我已经做了上面提到的计算部分。我需要一个功能,可以存储在机器中发现的一百张etc钞票,每次使用都必须减少。(例如,上面给出的例子,如果每个纸币有10张,那么在交易后,每个纸币只剩下8张。)

程序还必须询问用户是否想在每次交易后进行另一笔交易。如果没有足够的音符来做trans。该项目必须以资金不足为由退出。到目前为止,我得到了(我将在完成存储后添加其他笔记):

void Transaction(int dollars, int& thousands, int& hundreds)
{
 thousands=(dollars/1000);
dollars-=thousands*1000;
 hundreds=(dollars/100);
dollars-=hundreds*20;
 }
 int main(void)
 {
 int dollars; 
 int thousands=0;
 int hundreds=0;
 cout<<"Enter the amount:";
 cin>> dollars;
 Transaction(dollars,thousands,hundreds);
 cout<<"$1000 Notes:"<< thousands <<endl;
 cout<<"$100 Notes:"<< hundreds <<endl;
 }
#include<iostream>
#include <cstdlib>
using namespace std;
void Transaction(int dollars, int& thousands, int& hundreds, int& p_thousands, int& p_hundreds)
{
  if(p_thousands*1000 + p_hundreds*100 > dollars)
  {
 thousands=(dollars/1000);
  dollars-=thousands*1000;
  hundreds=(dollars/100);
  dollars-=hundreds*20;
  }
  else
  {
  cout << "Not Enough Funds" <<endl;
  exit(0);
  }
  }
 int main(void)
 {
 int dollars; 
 int p_thousands=10;
 int p_hundreds=10;
 int thousands=0;
 int hundreds=0;
 char c;
do
{
cout<<"Enter the amount:";
cin>> dollars;
Transaction(dollars,thousands,hundreds,p_thousands,p_hundreds);
p_thousands  -= thousands;
p_hundreds -= hundreds;
cout<<"$1000 Notes:"<< thousands <<endl;
cout<<"$100 Notes:"<< hundreds <<endl;
// for debugging purpose
//cout<<"$1000 Notes present:" <<p_thousands <<endl;
//cout<<"$100 Notes present:" <<p_hundreds <<endl;
cout<<"Press y for another transaction" <<endl;
cin>>c;
}while(c=='y');

}
#include<iostream>
#include <cstdlib>
using namespace std;
void Transaction(int dollars, int& thousands, int& hundreds, int& p_thousands, int&     p_hundreds)
{
if(p_thousands*1000 + p_hundreds*100 >= dollars)
{
  if(dollars/1000>p_thousands)
  {
  dollars -=p_thousands*1000;
  thousands =p_thousands;
  }
  else
  {
  thousands=(dollars/1000);
  dollars-=thousands*1000;
  }
  if(dollars/100>p_hundreds)
  {
  dollars -=p_hundreds*100;
  hundreds =p_hundreds;
  }
  else
  {
  hundreds=(dollars/100);
  dollars-=hundreds*20;
  }
}
else
{
cout << "Not Enough Funds" <<endl;
exit(0);
}
}
int main(void)
{
int dollars; 
int p_thousands=10;
int p_hundreds=10;
int thousands=0;
int hundreds=0;
char c;
do
{
cout<<"Enter the amount:";
cin>> dollars;
Transaction(dollars,thousands,hundreds,p_thousands,p_hundreds);
p_thousands  -= thousands;
p_hundreds -= hundreds;
cout<<"$1000 Notes:"<< thousands <<endl;
cout<<"$100 Notes:"<< hundreds <<endl;
// for debugging purpose
cout<<"$1000 Notes present:" <<p_thousands <<endl;
cout<<"$100 Notes present:" <<p_hundreds <<endl;
cout<<"Press y for another transaction" <<endl;
cin>>c;
}while(c=='y');

}
相关文章: