Fix Lesson 2 Task 1
This commit is contained in:
parent
70cc836f05
commit
52c071c46c
1 changed files with 28 additions and 19 deletions
|
@ -15,15 +15,30 @@ int main()
|
|||
cout << "Enter action (1 - add money, 2 - remove money, 3 - display all balances): ";
|
||||
cin >> action;
|
||||
|
||||
if (action == 1 || action == 2) {
|
||||
if (action < 1 || action > 3) {
|
||||
cout << "Invalid action" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (action != 3) {
|
||||
int number = 0;
|
||||
int money = 0;
|
||||
cout << "Enter account number: ";
|
||||
cin >> number;
|
||||
if (number >= 0 && number < 10) {
|
||||
|
||||
if (number < 0 || number > 10) {
|
||||
cout << "Invalid account number." << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
cout << "Enter the amount of money: ";
|
||||
cin >> money;
|
||||
if (money > 0) {
|
||||
|
||||
if (money <= 0) {
|
||||
cout << "The amount must be positive." << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (action == 1) {
|
||||
accounts[number] += money;
|
||||
cout << "Money added." << endl;
|
||||
|
@ -33,14 +48,8 @@ int main()
|
|||
} else
|
||||
cout << "Not enough money." << endl;
|
||||
} else
|
||||
cout << "The amount must be positive." << endl;
|
||||
} else
|
||||
cout << "Invalid account number." << endl;
|
||||
} else if (action == 3) {
|
||||
for (int account = 0; account < 10; ++account)
|
||||
cout << "Account " << account << ": " << accounts[account] << endl;
|
||||
} else
|
||||
cout << "Invalid action." << endl;
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue