Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- #define RUSSIAN 1
- #define ENGLISH 2
- int languageChoice = RUSSIAN; // Установка русского языка по умолчанию
- void outputMessage(const std::string& message_ru, const std::string& message_en) {
- if (languageChoice == RUSSIAN) {
- std::cout << message_ru << std::endl;
- } else if (languageChoice == ENGLISH) {
- std::cout << message_en << std::endl;
- }
- }
- int main() {
- const int initialBalance = 10000;
- int balance = initialBalance;
- const int maxWithdrawal = 150000;
- std::map<int, int> denominations = { {5000, 100}, {1000, 100}, {500, 100}, {100, 100}, {50, 100} };
- std::string operationChoice;
- std::cout << "Choose language / Выберите язык:" << std::endl;
- std::cout << "1. Русский / Russian" << std::endl;
- std::cout << "2. Английский / English" << std::endl;
- std::cin >> languageChoice;
- while (true) {
- outputMessage("Ваш текущий баланс: " + std::to_string(balance) + " рублей", "Your current balance: " + std::to_string(balance) + " rubles");
- outputMessage("Выберите действие:", "Choose an action:");
- outputMessage("1. Посмотреть баланс", "1. Check balance");
- outputMessage("2. Снять деньги", "2. Withdraw money");
- outputMessage("3. Пополнить баланс", "3. Deposit money");
- outputMessage("Введите номер действия: ", "Enter the action number: ");
- std::cin >> operationChoice;
- if (operationChoice == "1") {
- outputMessage("Ваш текущий баланс: " + std::to_string(balance) + " рублей", "Your current balance: " + std::to_string(balance) + " rubles");
- } else if (operationChoice == "2") {
- int amount;
- std::string receiptChoice;
- outputMessage("Хотите получить чек при снятии денег? (да/нет): ", "Do you want a receipt when withdrawing money? (yes/no): ");
- std::cin >> receiptChoice;
- if (!(receiptChoice == (languageChoice == RUSSIAN ? "да" : "yes") || receiptChoice == (languageChoice == RUSSIAN ? "нет" : "no"))) {
- outputMessage("Выберите 'да' или 'нет'.", "Choose 'yes' or 'no'.");
- continue;
- }
- outputMessage("Введите сумму для снятия (не более " + std::to_string(maxWithdrawal) + " рублей): ", "Enter the amount to withdraw (up to " + std::to_string(maxWithdrawal) + " rubles): ");
- std::cin >> amount;
- if (amount > 0 && amount <= maxWithdrawal && amount <= balance) {
- if (receiptChoice == (languageChoice == RUSSIAN ? "да" : "yes")) {
- outputMessage("Чек о снятии денег:", "Money withdrawal receipt:");
- }
- for (auto it = denominations.rbegin(); it != denominations.rend(); ++it) {
- int denom = it->first;
- int& count = it->second;
- while (amount >= denom && count > 0) {
- amount -= denom;
- balance -= denom;
- count--;
- if (receiptChoice == (languageChoice == RUSSIAN ? "да" : "yes")) {
- outputMessage("Выдано: " + std::to_string(denom) + " рублей", "Dispensed: " + std::to_string(denom) + " rubles");
- }
- }
- }
- if (receiptChoice == (languageChoice == RUSSIAN ? "да" : "yes")) {
- outputMessage("Осталось денег на счету: " + std::to_string(balance) + " рублей", "Remaining balance: " + std::to_string(balance) + " rubles");
- }
- } else {
- outputMessage("Невозможно выполнить операцию. Проверьте сумму и наличие необходимых средств.", "Unable to perform the operation. Check the amount and the availability of funds.");
- }
- } else if (operationChoice == "3") {
- int amount;
- const int maxDeposit = 200000;
- outputMessage("Введите сумму для пополнения (не более " + std::to_string(maxDeposit) + " рублей): ", "Enter the amount to deposit (up to " + std::to_string(maxDeposit) + " rubles): ");
- std::cin >> amount;
- if (amount > 0 && amount <= maxDeposit) {
- if (balance + amount <= maxDeposit) {
- balance += amount;
- outputMessage("Баланс успешно пополнен. Новый баланс: " + std::to_string(balance) + " рублей", "Balance successfully deposited. New balance: " + std::to_string(balance) + " rubles");
- } else {
- outputMessage("Превышено максимально возможное пополнение. Попробуйте сумму до " + std::to_string(maxDeposit - balance) + " рублей.", "Exceeded maximum deposit amount. Try an amount up to " + std::to_string(maxDeposit - balance) + " rubles.");
- }
- } else {
- outputMessage("Некорректная сумма для пополнения. Проверьте, что вносимая сумма не превышает " + std::to_string(maxDeposit) + " рублей.", "Incorrect deposit amount. Make sure the deposited amount does not exceed " + std::to_string(maxDeposit) + " rubles.");
- }
- } else {
- outputMessage("Некорректный выбор действия. Пожалуйста, выберите снова.", "Incorrect choice of action. Please choose again.");
- }
- // Для продолжения работы
- std::string continueChoice;
- outputMessage("Хотите продолжить работу? (да/нет): ", "Do you want to continue? (yes/no): ");
- std::cin >> continueChoice;
- // Продолжить или завершить работу в зависимости от ввода
- if (continueChoice != (languageChoice == RUSSIAN ? "да" : "yes")) {
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement