#C14954. ATM Transaction Simulator
ATM Transaction Simulator
ATM Transaction Simulator
This problem simulates an Automated Teller Machine (ATM) transaction. Given an initial account balance, a withdrawal amount, and a deposit amount, your task is to compute the final account balance after performing the transactions. The final balance is computed as:
\(\text{Final Balance} = \text{Initial Balance} - \text{Withdrawal Amount} + \text{Deposit Amount}\)
However, if any of the input amounts is negative, your program should output "Amounts must be non-negative." If the withdrawal amount exceeds the initial balance, output "Insufficient funds for the withdrawal." If any of the inputs cannot be interpreted as a number, output "All amounts must be numbers."
inputFormat
The input consists of three values separated by spaces:
- initial_balance: a floating-point number representing the starting balance in the account.
- withdrawal_amount: a floating-point number representing the amount to withdraw.
- deposit_amount: a floating-point number representing the amount to deposit.
outputFormat
Output a single line. If the transaction is successful, print the final balance as a floating point number with one decimal place. Otherwise, print one of the error messages exactly as follows:
- "Amounts must be non-negative."
- "Insufficient funds for the withdrawal."
- "All amounts must be numbers."
500 100 200
600.0