Question: You are to write a program that reads in lines of input using scanf or cin, and file redirection, process the data, and then output
You are to write a program that reads in lines of input using scanf or cin, and file redirection, process the data, and then output the results using printf or cout. This means you can use C or C++ style I/O as is your personal preference. Use the file named "transactiondata" Use command line redirection to execute as in ./a.out < transactiondata to compile use g++ ass1.cpp to create the executable file a.out 1. Each line of the named "transaction" data file begins with an 'e', 'c', or 't'. 2. Lines beginning with 'e' will have an integer employee ID and an employee name. 3. Lines beginning with 'c' will have an integer customer ID, customer name, and a floating point account balance. 4. Lines beginning with a 't' will have a customer ID, employee ID, a 'w' or 'd' representing withdrawal or deposit, and a floating point transaction amount. 5. Lines beginning with an 'e' and 'c' may be intermingled, but all 'e' and 'c' lines will come before lines beginning with 't'. 6. There will be at most 50 employees and 50 customers, and an unknown number of transactions. Names will be at 1. 2. 3. 4. The data: most 15 characters long. An example data file is shown below: e 5 Elden c 3 Felipe 55342.51415 e 3 Leonardo e 1 Yong c 9 Alessandra 8114.541862 c 6 Marnie e 8 Kourtney c2Lou c 5 Numbers e 4 Jarvis e 9 Marlen e 10 Florance c 1 Devon e 2 Elliott c 8 Justina c 10 Reyna e 6 Antonetta e 7 Florene c 4 Merrill c 7 Marlana t1 8w4924.86 t9 6d3220.42 t6 1w127.62 t9 8w5566.7 t9 8d5414.55 t5 7w9422.35 t 9 10 d 1382.07 t4 7d6131.07 t8 2w2362.22 t 8 10 d 5834.48 t5 4w5150.73 t6 2d3795.96 t1 9w3919.45 t5 2w5037.31 t3 9w8129.21 t8 6d1235.67 t2 4d6901.28 15287.78233 95053.44742 51245.66138 56442.27875 73723.84849 82946.53205 98281.82784 33252.21805 Page1! of2 t 8 10 d 5599.44 t 6 9 d 1936.16 t 7 9 d 7363.98 Your program should read in the employee and customer information and update the customer account balance depending on the transaction. For example, t 1 8 w 4924.86 means to update the balance for customer 1 by withdrawing 4924.86 from Devon's account balance of 56442.27875. For each transaction, output customer name, the employee name, a plus sign for deposit or a minus sign for withdrawal, the transaction amount, and the new balance after the transaction with two decimal places (truncate values; do not worry about rounding). For example, the output for the example transaction above would appear as (include the line of digits): 123456789012345678901234567890123456789012345678901234567890 Devon Kourtney -$4924.86 $ 51517.42 For the above the data file, your output would be: 123456789012345678901234567890123456789012345678901234567890 Devon Alessandra Marnie Alessandra Alessandra Numbers Alessandra Merrill Justina Justina Numbers Marnie Devon Numbers Felipe Justina Lou Justina Marnie Marlana Kourtney -$4924.86 $ 51517.42 Antonetta +$3220.42 $ 11334.96 Yong -$ 127.62 $ 15160.16 Kourtney -$5566.70 $ 5768.26 Kourtney +$5414.55 $ 11182.81 Florene -$9422.35 $ 41823.31 Florance +$1382.07 $ 12564.88 Florene +$6131.07 $104412.90 Elliott -$2362.22 $ 71361.63 Florance +$5834.48 $ 77196.11 Jarvis -$5150.73 $ 36672.58 Elliott +$3795.96 $ 18956.12 Marlen -$3919.45 $ 47597.97 Elliott -$5037.31 $ 31635.27 Marlen -$8129.21 $ 47213.30 Antonetta +$1235.67 $ 78431.78 Jarvis +$6901.28 $101954.73 Florance +$5599.44 $ 84031.22 Marlen +$1936.16 $ 20892.28 Marlen +$7363.98 $ 40616.20 You should create structures to hold the data for each employee and for the customers, including their current balance. Then create arrays of these structures. You will need counters to keep track of the next available space in each array, as well as to use for loop control when searching for information. The arrays may be fixed size base on the limits provided above. When you receive a 't" command you can get the employee name and customer name and balance from the arrays. Be sure to update the customer balance to complete the transaction processing. You will output the information as described above. When you have completed and tested your program on the CSE Linux Servers, you will need to download it to your local machine, and then upload it to the assignment box in Canvas for Ass1. Be sure to include all the files needed to compile, link and run your program if you created more than a single program file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
