Quantcast
Jump to content

Welcome to HeLLsGamers

Welcome to HeLLsGamers, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of HeLLsGamers by signing in or creating an account.
  • Start new topics and reply to others
  • Subscribe to topics and forums to get email updates
  • Get your own profile page and make new friends
  • Send personal messages to other members.
Sign in to follow this  
Destroy

Help With Code

Recommended Posts

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 by Destroy

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by Destroy

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy