Hello,
I'm having trouble understanding what one of my assignments requires me to do. This is a data structures ADT program. I tried emailing the teacher, but she could only manage to clarify a few things for me... Maybe there's just something that I'm not seeing. If someone could make sense of this, please help me out! I would really appreciate it!
Write a program that does the following:
1. Prompts the user to enter the name of the input file.
2. Reads the data in the file into a stack. Each time an S is encountered process data if possible and display the results(see example below), otherwise display an error message.
3. If the stack is not empty, save it to a file (get the name of the output file from the user). You have to be able to build the stack back from the file exactly as it is.
Example:
02/15/2008 B 100 3.00
02/15/2009 B 200 5.00
02/15/2010 B 300 10.00
02/15/2011 S 400 100.00
Display the following:
Feb. 15, 2011
400 * 100 = 40000
300 * 10 = 3000
100 * 5 = 500
Gain: 40000 -3500 = 36500
100 shares left out of 200 shares at $5.00 each.
Here is the file that I'm supposed to use:
02/15/1995 S 10000 3.71
02/15/1995 B 10000 3.71
02/15/2009 B 1000 16.15
01/27/2011 S 5000 28.87
09/02/2011 B 100 25.80
09/06/2011 B 500 25.51
09/08/2011 S 700 26.52
09/09/2011 B 2000 25.74
09/15/2011 S 1000 27.00
09/22/2011 B 300 25.00
09/22/2011 s 30000 25.00
09/26/2011 B 100 25.50
-First, the file starts with an S... so do I just ignore the first term since there is nothing above it? And since there are multiple S's, what exactly do I process? The whole file or just what is above the S up to the last previous S? Would I need multiple stacks or is one enough?
-Lastly, were supposed to use #include "stacks.ADT", however when I have this in my visual studio, it doesn't recognize this. What can I do?
-Thank you so much for your time! I know this is a lot of information, but I am very confused and worried that if I can't even figure out the algorithm, then I can't write the code. I hope what I'm asking makes sense.