CS 162 Spring 2000 Assignment 1 – Review Introductory Programming with C++ I/O
100 pointsAssigned: 01/24/2000
Due: 01/31/2000 at the start of class.
Pre-Lab (Do Before Lab): Bring an empty (or nearly empty) disk. Plan out sequence of statements needed for program.
Pairs: You may work in pairs if you want. Note, during the course of the semester, you cannot pair with any one person more than twice. If you work in a pair, turn in ONE copy that is the work of both of you, with both of your names on it. Each member of the pair will receive the same grade for that lab. In such a partnership, students must share as equally as possible the work and learning. Working together with truly shared effort and learning can be a positive experience. However, simply giving/receiving code from someone defeats the learning process. If substantial parts of a program are taken from non-partners, that is plagiarism. The copier and copyee will each receive a zero.
Main Assignment:
TechStocksRUs Brokerage wants you to write a program to help display the trend of a stock for a month. Create an array of prices – position 0 is the price going into the month, position 1 has the closing price on the first of the month, position 2 has the closing price on the 2nd, etc. Assume stocks are traded on weekends to keep this from getting too messy. Ask the user for the name of the stock, then for each of the days in the month, ask the user for the closing price of the stock. To handle different length months, have the user type a negative value to indicate the end of the month (but this isn't allowed before the 29th!) . At the end of the month, display info as shown below, showing for each day the closing price, change from the previous day, and whether the closing price was above the average (mean) for the month.
Details:
Sample interaction with the user:
What company are we tracking?
EJunk.comWhat is the opening price of the stock for eJunk.com 12.5
You will be asked to enter a closing price for the stock for each day in the month. Enter a negative number when there are no more days in month
What was the closing price for eJunk.com on day 1 -1
That price is invalid, please enter a positive price
What was the closing price for eJunk.com on day 1
12.75What was the closing price for eJunk.com on day 2
12.875What was the closing price for eJunk.com on day 3
13.125What was the closing price for eJunk.com on day 4
13.5What was the closing price for eJunk.com on day 5
-1That price is invalid, please enter a positive price
What was the closing price for eJunk.com on day 5
14.125What was the closing price for eJunk.com on day 6
15.25What was the closing price for eJunk.com on day 7
16.75What was the closing price for eJunk.com on day 8
18.5What was the closing price for eJunk.com on day 9
20.875What was the closing price for eJunk.com on day 10
24What was the closing price for eJunk.com on day 11
29.5What was the closing price for eJunk.com on day 12
36.875What was the closing price for eJunk.com on day 13
34.5What was the closing price for eJunk.com on day 14
33.125What was the closing price for eJunk.com on day 15
30.25What was the closing price for eJunk.com on day 16
25.125What was the closing price for eJunk.com on day 17
19.25What was the closing price for eJunk.com on day 18
13.125What was the closing price for eJunk.com on day 19
9.75What was the closing price for eJunk.com on day 20
8.5What was the closing price for eJunk.com on day 21
7.875What was the closing price for eJunk.com on day 22
7.375What was the closing price for eJunk.com on day 23
7.125What was the closing price for eJunk.com on day 24
6.875What was the closing price for eJunk.com on day 25
6.75What was the closing price for eJunk.com on day 26
7.125What was the closing price for eJunk.com on day 27
7.5What was the closing price for eJunk.com on day 28
7.875What was the closing price for eJunk.com on day 29
-1Results for Company: eJunk.com
Mean price for month: 16.438
Day Open Close Change Compare to Ave
1 12.500 12.750 0.250
2 12.750 12.875 0.125
3 12.875 13.125 0.250
4 13.125 13.500 0.375
5 13.500 14.125 0.625
6 14.125 15.250 1.125
7 15.250 16.750 1.500 +
8 16.750 18.500 1.750 +
9 18.500 20.875 2.375 +
10 20.875 24.000 3.125 +
11 24.000 29.500 5.500 +
12 29.500 36.875 7.375 +
13 36.875 34.500 -2.375 +
14 34.500 33.125 -1.375 +
15 33.125 30.250 -2.875 +
16 30.250 25.125 -5.125 +
17 25.125 19.250 -5.875 +
18 19.250 13.125 -6.125
19 13.125 9.750 -3.375
20 9.750 8.500 -1.250
21 8.500 7.875 -0.625
22 7.875 7.375 -0.500
23 7.375 7.125 -0.250
24 7.125 6.875 -0.250
25 6.875 6.750 -0.125
26 6.750 7.125 0.375
27 7.125 7.500 0.375
28 7.500 7.875 0.375
Hand-in:
1) Listing of the program
2) Disk with your .cpp file and your working .exe file. NAME YOUR PROGRAM FILE yourlastname1.cpp; Name your project yourlastname1 so that the executable will be yourlastname1.exe. If you are working in pairs, use both last names (e.g. redmondsmith1.cpp)
Miscellaneous:
1) Make your program work like shown above. If you have any questions about what should be done, please ask!!
2) MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). Test it more than once - I will! Your program needs to be able to handle any inputs including catching invalid inputs.
3) Remember: Indentation, meaningful variable names, symbolic constants, and meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your program in order to get full credit. Also make sure you put YOUR NAME(s), section, and e-mail address in comments at the beginning of the program.
4) You will save time in initial testing if you temporarily pretend that you can have a month with a small number of days (10?). But remember to change that back!!