Ontwerp een consoletoepassing die een bankrekening simuleert. Maak hiervoor de klasse Bankrekening. Voorzie 2 methoden, namelijk Opname en Storting, en een property HuidigSaldo. Aan de gebruiker wordt telkens een bedrag gevraagd. Bij een negatief bedrag gebeurt een opname en bij een positief bedrag een storting. Wanneer de gebruiker de letter “S” invoert, wordt het saldo getoond. Bij invoer van de tekst “END” wordt het programma afgesloten.
Translated to English:
Design a console application that simulates a bank account. To do this, create the Bank account class. Provide 2 methods, namely Withdrawal and Deposit, and a CurrentBalance property. The user is always asked for an amount. A withdrawal is made with a negative amount and a deposit with a positive amount. When the user enters the letter “S”, the balance is shown. Entering the text “END” will close the program.
Naimish MakwanaPosted Feb 14, 2023, 5:55 AM
You can try below code.
Thanks
Naimish
Tuhin PaulPosted Feb 14, 2023, 5:42 AM
Here's an example implementation of the console application as per the above statement:
The BankAccount class defines the bank account with Withdrawal, Deposit, and CurrentBalance methods. The Main method of the console application creates an instance of BankAccount and enters a loop to repeatedly ask the user for an amount. If the user enters "S", the current balance is displayed. If the user enters "END", the loop is exited and the program terminates. If the user enters a valid number, the Withdrawal or Deposit method is called with the appropriate amount. If the input is not a valid number, an error message is displayed and the loop continues.