In .java
Write a program that simulates 2 bank transactions. The user will enter: the original amount in the bank, the money for transaction 1 and the money for transaction. If a transaction has a negative number it means that money was removed from bank (an withdrawal). If a transaction has a positive number it means that money was deposited in the bank. Hint: if you add a negative number you are effectively subtracting. E.g. 100 + (-10) = 90. Sample run 1:
This program will simulate 2 bank transactions.
Enter the original amount of money in the bank: 1000.5
Enter the 1st transaction: 35 Current amount: 1035.50
Enter the 2nd transaction: -20.1
Current amount: 1015.40
The original amount was: 1000.50
//BankTransactions.java import java.util.Scanner; public class BankTransactions { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double orig; System.out.print("Enter the original amount of money in the bank: "); orig = scan.nextDouble(); double n = orig; System.out.print("Enter the 1st transaction: "); double first = scan.nextDouble(); n = n + first; System.out.printf("Current amount = %.2f\n",n); System.out.print("Enter the 2nd transaction: "); double second = scan.nextDouble(); n = n + second; System.out.printf("Current amount = %.2f\n",n); System.out.printf("The original amount was: %.2f\n",orig); } }
Get Answers For Free
Most questions answered within 1 hours.