编写一个程序,用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
我有一个部分要求您输入金额,它将输出它必须是什么类型的钞票。(例如,对于$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');
}
相关文章:
- 我试图制作一个程序,要求用户输入问题和答案,但程序循环不正确
- 我写了一个C++程序来模拟Enigma机器.我没有得到输出
- 如何使用C++读取另一个程序中的源代码输出
- 3-3. 编写一个程序来计算每个不同单词在其输入中出现的次数
- 我的目标是编写一个程序来计算和存储字符串在字符数组中出现的位置
- 使用另一个程序调用正在运行的 C++ 程序中的函数
- 我正在尝试制作一个程序,在添加 n 天(整数)后告诉一个人什么是一天(例如星期一等)
- 编写一个程序,帮助Tudio将MIDI音符转换为名称和八度音阶
- 有没有办法在一个C++程序中同时使用 FFTW 和 cuFFTW?
- 一个C++程序,用于在输入位数时输出具有特定位数的 .txt 文件中的所有数字
- C++将结构复制到另一个程序的资源
- 我编写了一个程序来显示数组的内容,但它显示的是它的地址
- 我已经做了一个程序来使用队列链C++表显示学生姓名和身高,现在我想以我不知道如何显示的顺序显示它
- 我需要编写一个程序来读取一个文件,该文件将输出所有唯一的整数,如果已经看到整数,它将被关闭
- 仅在 boost::hash_combine 中运行一个程序期间保证确定性
- 如何制作一个程序,它使用特定单词加密和解密消息?
- 尝试创建一个程序来查找非二叉树的高度.最终得到一个很长的循环,没有答案
- 编写一个程序,提示用户输入一个整数,然后输出数字的单个数字和数字的总和
- 如何编写一个程序来打印特定基数的前N个数字
- 如何创建一个C++程序来读取字符串数组中的信息,然后将其排序到类中?