Advertisement
Maestro1

gg

May 17th, 2024
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. #define RUSSIAN 1
  6. #define ENGLISH 2
  7.  
  8. int languageChoice = RUSSIAN; // Установка русского языка по умолчанию
  9.  
  10. void outputMessage(const std::string& message_ru, const std::string& message_en) {
  11.     if (languageChoice == RUSSIAN) {
  12.         std::cout << message_ru << std::endl;
  13.     } else if (languageChoice == ENGLISH) {
  14.         std::cout << message_en << std::endl;
  15.     }
  16. }
  17.  
  18. int main() {
  19.     const int initialBalance = 10000;
  20.     int balance = initialBalance;
  21.     const int maxWithdrawal = 150000;
  22.     std::map<int, int> denominations = { {5000, 100}, {1000, 100}, {500, 100}, {100, 100}, {50, 100} };
  23.  
  24.     std::string operationChoice;
  25.  
  26.     std::cout << "Choose language / Выберите язык:" << std::endl;
  27.     std::cout << "1. Русский / Russian" << std::endl;
  28.     std::cout << "2. Английский / English" << std::endl;
  29.  
  30.     std::cin >> languageChoice;
  31.  
  32.     while (true) {
  33.         outputMessage("Ваш текущий баланс: " + std::to_string(balance) + " рублей", "Your current balance: " + std::to_string(balance) + " rubles");
  34.         outputMessage("Выберите действие:", "Choose an action:");
  35.         outputMessage("1. Посмотреть баланс", "1. Check balance");
  36.         outputMessage("2. Снять деньги", "2. Withdraw money");
  37.         outputMessage("3. Пополнить баланс", "3. Deposit money");
  38.         outputMessage("Введите номер действия: ", "Enter the action number: ");
  39.  
  40.         std::cin >> operationChoice;
  41.  
  42.         if (operationChoice == "1") {
  43.             outputMessage("Ваш текущий баланс: " + std::to_string(balance) + " рублей", "Your current balance: " + std::to_string(balance) + " rubles");
  44.         } else if (operationChoice == "2") {
  45.             int amount;
  46.             std::string receiptChoice;
  47.  
  48.             outputMessage("Хотите получить чек при снятии денег? (да/нет): ", "Do you want a receipt when withdrawing money? (yes/no): ");
  49.             std::cin >> receiptChoice;
  50.  
  51.             if (!(receiptChoice == (languageChoice == RUSSIAN ? "да" : "yes") || receiptChoice == (languageChoice == RUSSIAN ? "нет" : "no"))) {
  52.                 outputMessage("Выберите 'да' или 'нет'.", "Choose 'yes' or 'no'.");
  53.                 continue;
  54.             }
  55.  
  56.             outputMessage("Введите сумму для снятия (не более " + std::to_string(maxWithdrawal) + " рублей): ", "Enter the amount to withdraw (up to " + std::to_string(maxWithdrawal) + " rubles): ");
  57.             std::cin >> amount;
  58.  
  59.             if (amount > 0 && amount <= maxWithdrawal && amount <= balance) {
  60.                 if (receiptChoice == (languageChoice == RUSSIAN ? "да" : "yes")) {
  61.                     outputMessage("Чек о снятии денег:", "Money withdrawal receipt:");
  62.                 }
  63.  
  64.                 for (auto it = denominations.rbegin(); it != denominations.rend(); ++it) {
  65.                     int denom = it->first;
  66.                     int& count = it->second;
  67.  
  68.                     while (amount >= denom && count > 0) {
  69.                         amount -= denom;
  70.                         balance -= denom;
  71.                         count--;
  72.                         if (receiptChoice == (languageChoice == RUSSIAN ? "да" : "yes")) {
  73.                             outputMessage("Выдано: " + std::to_string(denom) + " рублей", "Dispensed: " + std::to_string(denom) + " rubles");
  74.                         }
  75.                     }
  76.                 }
  77.  
  78.                 if (receiptChoice == (languageChoice == RUSSIAN ? "да" : "yes")) {
  79.                     outputMessage("Осталось денег на счету: " + std::to_string(balance) + " рублей", "Remaining balance: " + std::to_string(balance) + " rubles");
  80.                 }
  81.             } else {
  82.                 outputMessage("Невозможно выполнить операцию. Проверьте сумму и наличие необходимых средств.", "Unable to perform the operation. Check the amount and the availability of funds.");
  83.             }
  84.  
  85.         } else if (operationChoice == "3") {
  86.             int amount;
  87.             const int maxDeposit = 200000;
  88.  
  89.             outputMessage("Введите сумму для пополнения (не более " + std::to_string(maxDeposit) + " рублей): ", "Enter the amount to deposit (up to " + std::to_string(maxDeposit) + " rubles): ");
  90.             std::cin >> amount;
  91.  
  92.             if (amount > 0 && amount <= maxDeposit) {
  93.                 if (balance + amount <= maxDeposit) {
  94.                     balance += amount;
  95.                     outputMessage("Баланс успешно пополнен. Новый баланс: " + std::to_string(balance) + " рублей", "Balance successfully deposited. New balance: " + std::to_string(balance) + " rubles");
  96.                 } else {
  97.                     outputMessage("Превышено максимально возможное пополнение. Попробуйте сумму до " + std::to_string(maxDeposit - balance) + " рублей.", "Exceeded maximum deposit amount. Try an amount up to " + std::to_string(maxDeposit - balance) + " rubles.");
  98.                 }
  99.             } else {
  100.                 outputMessage("Некорректная сумма для пополнения. Проверьте, что вносимая сумма не превышает " + std::to_string(maxDeposit) + " рублей.", "Incorrect deposit amount. Make sure the deposited amount does not exceed " + std::to_string(maxDeposit) + " rubles.");
  101.             }
  102.         } else {
  103.             outputMessage("Некорректный выбор действия. Пожалуйста, выберите снова.", "Incorrect choice of action. Please choose again.");
  104.         }
  105.  
  106.         // Для продолжения работы
  107.         std::string continueChoice;
  108.         outputMessage("Хотите продолжить работу? (да/нет): ", "Do you want to continue? (yes/no): ");
  109.         std::cin >> continueChoice;
  110.  
  111.         // Продолжить или завершить работу в зависимости от ввода
  112.         if (continueChoice != (languageChoice == RUSSIAN ? "да" : "yes")) {
  113.             break;
  114.         }
  115.     }
  116.  
  117.     return 0;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement