Destroy Posted October 16, 2018 Share Posted October 16, 2018 (edited) Write a C++ program to simulate typical bank account processes by incorporating the following requirements: 1. Declare a variable to store the account number as string with no more than 8 characters. 2. Declare a variable to store the transaction date as a string with no more than 10 characters. 3. Declare a variable to store the transaction description as a string with no more than 36 characters. 4. Declare a variable to store the transaction amount as a decimal value. 5. Declare a variable to store the account balance as a decimal value. 6. Request the account number from the user and store this value in the variable you previously created. 7. Request the transaction date from the user and store this value in the variable you previously created. 8. Request the transaction description from the user and store this value in the variable you previously created. 9. Request the transaction amount from the user and store this value in the variable you previously created. 10. Request the account balance from the user and store this value in the variable you previously created. 11. Using the data that was assigned to the variables in the previous steps, print to the standard output a transaction report formatted exactly as follows: CPSC-120 Fall 2018 Steve May ======================================================================== ACCOUNT: 12345678 DATE DESCRIPTION AMOUNT BALANCE ========== ==================================== ========== ========== 03/01/2018 Initial Deposit 1000.00 1000.00 NOTE: The first line should have your own name. The data values on the report for the account, date, description, amount, and balance should come from the information you requested from the user and stored in the respective data variables. Ok thingis i dont understand how to create a string with no more than 8 character. https://gyazo.com/40...138ba56d9e8d08f this link is the code which works now https://gyazo.com/49...80fa423bf2c28d6 this is the terminal that ran the code https://gyazo.com/ee...ad66d1b2ccd7046 this is how they want to set it up to be but i dont know how to set up the setwidth between each other thats all i need help with now, the rest i figured out Edited October 16, 2018 by Destroy Quote Link to comment Share on other sites More sharing options...
Kevinyock Posted October 16, 2018 Share Posted October 16, 2018 For the setting the size of your string, use the resize function. Quote Link to comment Share on other sites More sharing options...
Pyrrhic Posted October 16, 2018 Share Posted October 16, 2018 Moved to a more appropriate section. If the assignment actually wants the variables to be strings then I think Kevin has the right idea. It sounds like using a char array might be fitting but I haven't done too much C++ so that is probably more trouble than it's worth. Quote Link to comment Share on other sites More sharing options...
Kevinyock Posted October 16, 2018 Share Posted October 16, 2018 Moved to a more appropriate section. If the assignment actually wants the variables to be strings then I think Kevin has the right idea. It sounds like using a char array might be fitting but I haven't done too much C++ so that is probably more trouble than it's worth. A char array would work but it is asking specifically for a string datatype. Quote Link to comment Share on other sites More sharing options...
Vel'Roz Posted October 16, 2018 Share Posted October 16, 2018 boi we're not bouta do your homework (and plus i dont know any C++) 2 Quote Link to comment Share on other sites More sharing options...
Destroy Posted October 16, 2018 Author Share Posted October 16, 2018 (edited) boi we're not bouta do your homework (and plus i dont know any C++) Moved to a more appropriate section. If the assignment actually wants the variables to be strings then I think Kevin has the right idea. It sounds like using a char array might be fitting but I haven't done too much C++ so that is probably more trouble than it's worth. https://gyazo.com/40...138ba56d9e8d08f this link is the code which works now https://gyazo.com/49...80fa423bf2c28d6 this is the terminal that ran the code https://gyazo.com/ee...ad66d1b2ccd7046 this is how they want to set it up to be but i dont know how to set up the setwidth between each other thats all i need help with now, the rest i figured out Edited October 16, 2018 by Destroy Quote Link to comment Share on other sites More sharing options...
Marco Posted October 16, 2018 Share Posted October 16, 2018 You may want to rather use printf/sprintf for proper output formatting: http://www.cplusplus.com/reference/cstdio/printf/?kw=printf / http://www.cplusplus.com/reference/cstdio/sprintf/?kw=sprintf Use printf to output to terminal window, or sprint to output a string line (if you need to also output to a file log). Quote Link to comment Share on other sites More sharing options...
Destroy Posted October 25, 2018 Author Share Posted October 25, 2018 This is the finished product https://gyazo.com/88399d16722cddb43fe614877c5d6137 https://gyazo.com/1459256cde60158862bb705a0bc8d03a https://gyazo.com/fd59279d14ca17c41abfb453968da66a Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.