wheelsmanx

StockScreen

Nov 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <stdlib.h>
  5. #include <iomanip>
  6.  
  7. using namespace std;
  8.  
  9. class singleStock {
  10. public:
  11. int open;
  12. int close;
  13. int width = 10;
  14. string symbol;
  15. int shareSold;
  16. void display() {
  17. cout << setw(width) << symbol << ", " << setw(width) << open << ", " << setw(width) << close << ", " << setw(width) << shareSold << endl;
  18. }
  19. };
  20.  
  21. singleStock fillStock(singleStock userInput) {
  22. userInput.close = rand() % 100;
  23. userInput.open = rand() % 100;
  24. userInput.shareSold = rand() % 100000;
  25. userInput.symbol = rand() % 80 + 50;
  26. return userInput;
  27. }
  28. vector<singleStock> randomStocks(int userInput) {
  29. vector<singleStock> returnObject;
  30. singleStock tempStock;
  31. for (int i = 0; i < userInput; i++) {
  32. returnObject.push_back(fillStock(tempStock));
  33. }
  34. return returnObject;
  35. }
  36. void displayStockVector(vector<singleStock> userInput) {
  37. cout << setw(10) << "symbol" << ", " << setw(10) << "close" << ", " << setw(10) << "open" << ", " << setw(10) << "shareSold" << endl;
  38. for (int i = 0; i < userInput.size(); i++) {
  39. singleStock tempPointer;
  40. tempPointer = userInput[i];
  41. tempPointer.display();
  42. }
  43.  
  44. }
  45. void main() {
  46. vector<vector <singleStock>> thisWeek;
  47. for (int i = 0; i < 7; i++) {
  48. vector<singleStock> tempStock = randomStocks(100);
  49. thisWeek.push_back(tempStock);
  50. cout << i << endl;
  51. displayStockVector(tempStock);
  52. }
  53. system("pause");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment