1
I need to make a program that simulates a bank ATM in C++, presenting a menu that has Deposit, Withdrawal and Payment of Tickets. How am I going to do that? I’ve done the following:
#include <iostream>
using namespace std;
bool ValidaNumeroAgencia (int agencia)
{
if (agencia >= 100 && agencia <= 999)
return true;
else
return false;
}
bool ValidaNumeroConta_Corrente (int conta)
{
if (conta >= 10000 && conta <= 99999)
return true;
else
return false;
}
float Deposito (float credito)
{
float novo_valor;
novo_valor = 500 + credito;
return novo_valor;
}
int Saque (int debito, int saldo)
{
if (debito <= saldo)
{
if (debito % 10)
return debito;
}
}
bool ValidaClienteEspecial (int saldo, int limite)
{
int n_limite;
if (saldo >= 10000 && ValidaClienteEspecial == false)
{
n_limite = limite + 5000;
return true;
cout << "Seu novo limite e de: " << n_limite << endl;
}
}
float Codigo_barras(int codigo, float valor, int saldo)
{
float n_saldo;
if (codigo >= 100000000000 && codigo <= 999999999999)
{
if (valor <= saldo)
{
n_saldo = saldo - valor;
return n_saldo;
}
}
}
float Saldo (float saldo)
{
cout << "Seu saldo e de:\n" "R$ " << saldo << endl;
}
int main ()
{
int n_agencia, n_conta_corrente, n, a;
ValidaNumeroAgencia(n_agencia);
ValidaNumeroConta_Corrente(n_conta_corrente);
do
{
cout << "Digite o Numero da sua Conta Corrente: ";
cin >> n_conta_corrente;
}
while (ValidaNumeroConta_Corrente(n_conta_corrente) == false);
do
{
cout << "Digite o Numero da sua Agencia: ";
cin >> n_agencia;
}
while (ValidaNumeroAgencia(n_agencia) == false);
cout << "\n\nSelecione qual opcao deseja realizar: ";
cout << "\n1 - Deposito";
cout << "\n2 - Saque";
cout << "\n3 - Pagamento de Boletos";
cout << "\n4 - Extrato";
cout << "\n0 - Sair\n";
return 0;
}
My question is, what will I do for the program to call the functions according to what the user choose in the menu? How can I continue the code above?
Give more details. What have you done? Where specifically is your question?
– Lucas Lima
I have already created some functions such as asking and validating the current account, the number of the user agency, etc... I printed a simple menu, look here: Cout << " n nSelect which option you want to perform: "; Cout << " n1 - Deposit"; Cout << " N2 - Withdrawal"; Cout << " N3 - Billet payment"; Cout << " N4 - Extract"; Cout << " N0 - Exit n"; And now I’m trying to do by switch to call each of the functions, but I’m not getting... Gives a tip ai pfv, q I can do. Thank you.
– user7292
Edit the question by adding this code and where the doubt is. This makes it easier to help.
– Lucas Lima
How do I put the code here in the comments? It is pq I entered the site has little time... kkk
– user7292
Edit your question. Click
Editar
below the question.– Lucas Lima
I’ve already edited... Help???
– user7292
Check the range of values you can represent with an int. In the case of 32 bits the range is: -2.147.483.648 to 2.147.483.647. You set the code variable to int and test: if (code >= 100000000000 && code <= 999999999999999).
– user4552