Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Could you help me write this code in c + + . Please be specific as I am a beginner and I will need to
Could you help me write this code in c Please be specific as I am a beginner and I will need to understand. Thank you! For this quest, you are going to start with the Account and Transaction structs from the previous quest and write four functions:
addTransaction will ask for information for a transaction, check for valid date input, and create the newly created Transaction. Try to use uniform initialization for the return instead of creating a temporary variable.
newAccount takes in the last ID used for an account, increments it and asks for all the information for a new Account, except for the ID The past in and incremented ID is used for that. Again, try to use uniform initialization for the return value.
getCurrentBalance calculates and returns the current balance of a passed in instance of the Account struct. This will need to be calculated based on the beginning balance and transactions on the account.
findAccount uses linear search to find the account by its ID and return the index in the vector for that account. return if not found
For the main function of this quest you will need to create a vector of Account structs and then should present a menu of options for the user.
"Add account" which calls the newAccount function and adds the new account to the vector of accounts
"Add Transaction"
asks for an account ID
calls findAccount to get the index of the account
calls addTransaction to create a new transaction and pushes it onto the correct Account's transactions vector.
"Get Balance"
asks for an account ID
calls findAccount to get the index of the account
calls getCurrentBlance, passing in the correct account
displays the account's balance on the terminal.
List Transactions
asks for an account ID
calls findAccount to get the index of the account
displays all transactions neatly on the screen.
HINT:: You may want to create a printTransaction function to help with this!
"Exit Program" This entire menu should be in a while loop that ends when this option is chosen.
Try to minimize the creation of temporary variables and take advantage of functions being first class citizens when you write this code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started