Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int alegereOperatie()
- {
- int raspuns = -1;
- cout << "=======================" << endl;
- cout << "Bun venit la bancomat!" << endl;
- cout << "=======================" << endl;
- cout << "1 -> Interogare sold" << endl;
- cout << "2 -> Retragere bani" << endl;
- cout << "3 -> Depunere bani" << endl;
- cout << "4 -> Iesire" << endl;
- cout << "Raspuns: ";
- cin >> raspuns;
- return raspuns;
- }
- void afisareSold(int& sold, string nume)
- {
- cout <<"Soldul tau, " << nume << " este de: " << sold << endl;
- }
- bool retragereSold(int& sold)
- {
- int valoare_de_retras;
- cout << "Cat vrei sa retragi? Sold curent: " << sold << endl;
- cout << "Raspuns: "; cin >> valoare_de_retras;
- if (valoare_de_retras > sold) return false;
- else {
- sold = sold - valoare_de_retras;
- return true;
- }
- }
- void depunereSold(int& sold)
- {
- int depunere;
- cout << "Introdu suma pe care vrei sa o depui: ";
- cin >> depunere;
- sold += depunere;
- }
- void analizareAlegere(int raspuns, int& sold, string nume)
- {
- switch (raspuns)
- {
- case 1:
- cout << "Afisare sold..." << endl;
- afisareSold(sold, nume);
- break;
- case 2:
- cout << "Se proceseaza retragerea..." << endl;
- if (retragereSold(sold) == true) {
- cout << "Succes! Sold curent: " << sold << endl;
- }
- else {
- cout << "Ai ales o suma prea mare!" << endl;
- cout << "Soldul tau este de: " << sold << endl;
- }
- break;
- case 3:
- cout << "Se proceseaza depunerea..." << endl;
- depunereSold(sold);
- cout << "Succes! Sold curent: " << sold << endl;
- break;
- case 4:
- cout << "Programul se va inchide." << endl;
- break;
- default:
- cout << "Ai ales o optiune necunoscuta" << endl;
- break;
- }
- }
- void mainLoop(int& sold, string nume)
- {
- int raspuns = -1;
- while (raspuns != 4)
- {
- raspuns = alegereOperatie();
- analizareAlegere(raspuns, sold, nume);
- }
- cout << "La revedere, " << nume << "!" << endl;
- }
- int main() {
- string nume = "Alina";
- int sold = 10000, numar_card = 74623983, varsta = 22;
- mainLoop(sold, nume);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment