Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java Program Description: This program will keep track of the balance and transaction history for a simple savings account. The program will first input

In java

Program Description: This program will keep track of the balance and transaction history for a simple savings account.

The program will first input an initial balance. It will then allow the user to input up to 20 transactions. Each transaction will be either a deposit or a withdrawal. The balance will be updated accordingly with each transaction being stored in an array of transactions. The format of each transaction will be a string that starts with either "w" or "d" followed by the amount of the transaction. Each transaction amount must include both dollars and cents. 2 types of errors can occur. The transaction type is invalid or the user tries to withdraw more money than is in the account. Display an error message if either of these situations occur. Use a sentinel value to stop entering in transactions. When the user enters the will display the transaction history and the final balance.

Transaction Type example: "deposit: 34.76" or "withdraw: 3.00"

Pseudo code/ algorithm BEGIN Calc Average Initialize array count to 0 Input the initial balance Input the first transaction (or sentinel) WHLE (the transaction is not the sentinel value) Get transaction type from the transaction that was entered IF (transaction type is invalid) Display error message Input next transaction ELSE Convert transaction amount to float IF (the user tries to withdraw too much money) Display error message ELSE IF (the transaction type is Deposit) Add the transaction amount to the balance ELE Subtract the transaction amount from the balance ENDIF Add balance to end of transaction, store in the array Add 1 to Array Count IF (the array is full) Set transaction to sentinel value to exit loop ELSE Input next transaction (or sentinel) END IF END IF END WHILE Display Transaction report heading FOR (each transaction in the transaction array) Display the transaction type, transaction amount, and new balance END FOR END Calc Average

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions