wheelsmanx

CPS 271 Machine Problem 3 Source

Apr 18th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <iomanip>
  5. #include "Publication.h"
  6.  
  7.  
  8.  
  9. using namespace std;
  10.  
  11.  
  12.  
  13. // classes
  14. class Books : public Publication {
  15. public:
  16. int pages;
  17. int sales, sales1, sales2;
  18. void ReadData(string inputA, double inputB, int inputC, int sales, int sales1, int sales2) {
  19. this->title = inputA;
  20. this->price = inputB;
  21. this->pages = inputC;
  22. this->sales = sales;
  23. this->sales1 = sales1;
  24. this->sales2 = sales2;
  25. }
  26. void DisplayData() {
  27. cout << "Title: " << title << endl << "Price: " << price << endl << "Length: " << pages << endl;
  28. }
  29. };
  30.  
  31. class Tapes : public Publication {
  32. public:
  33. double timeInMin;
  34. int sales, sales1, sales2;
  35. void ReadData(string inputA, double inputB, double inputC, int sales, int sales1, int sales2) {
  36. this->title = inputA;
  37. this->price = inputB;
  38. this->timeInMin = inputC;
  39. this->sales = sales;
  40. this->sales1 = sales1;
  41. this->sales2 = sales2;
  42. }
  43.  
  44. void DisplayData() {
  45. cout << "Title: " << title << endl << "Price: " << price << endl << "Length: " << timeInMin << endl;
  46. }
  47. };
  48.  
  49.  
  50.  
  51. //variables
  52. int temp, temp1, temp2;
  53. int RBuffer;
  54. string buffer_Title;
  55. double buffer_Price;
  56. int buffer_length;
  57. double buffer_lengthDouble;
  58.  
  59. void main() {
  60. vector<Books> vectorBooks;
  61. vector<Tapes> vectorTapes;
  62. for (int i = 0; i < 3; i++) {
  63. Books *BooksPtr = new Books;
  64. BooksPtr->ReadData("Gone With The Wind", 59.99, 566, 0, 0, 0);
  65. BooksPtr->DisplayData();
  66. vectorBooks.push_back(*BooksPtr);
  67. }
  68. for (int i = 0; i < 2; i++) {
  69. Tapes *TapesPtr = new Tapes;
  70. TapesPtr->ReadData("Beethoven", 99.99, 60, 0, 0, 0);
  71. TapesPtr->DisplayData();
  72. vectorTapes.push_back(*TapesPtr);
  73. }
  74. for (int i = 0; i < vectorBooks.size(); i++) {
  75. cout << "What are the sales for month 1 of the book " << vectorBooks[i].title << "?" << endl;
  76. cin >> temp;
  77. cout << "What are the sales for month 2 of the book " << vectorBooks[i].title << "?" << endl;
  78. cin >> temp1;
  79. cout << "What are the sales for month 3 of the book " << vectorBooks[i].title << "?" << endl;
  80. cin >> temp2;
  81. vectorBooks[i].sales = temp;
  82. vectorBooks[i].sales1 = temp1;
  83. vectorBooks[i].sales2 = temp2;
  84. }
  85. for (int i = 0; i < vectorTapes.size(); i++) {
  86. cout << "What are the sales for month 1 of the tape " << vectorTapes[i].title << "?" << endl;
  87. cin >> temp;
  88. cout << "What are the sales for month 2 of the tape " << vectorTapes[i].title << "?" << endl;
  89. cin >> temp1;
  90. cout << "What are the sales for month 3 of the tape " << vectorTapes[i].title << "?" << endl;
  91. cin >> temp2;
  92. vectorTapes[i].sales = temp;
  93. vectorTapes[i].sales1 = temp1;
  94. vectorTapes[i].sales2 = temp2;
  95.  
  96.  
  97. }
  98. for (Tapes c : vectorTapes) {
  99. cout << "Sales for tape " << c.title << endl;
  100. cout << setw(10) << left << "Month 1" << setw(10) << left << "Month 2" << setw(10) << left << "Month 3" << endl;
  101. cout << setw(10) << left << c.sales << setw(10) << left << c.sales1 << setw(10) << left << c.sales2 << endl << endl;
  102.  
  103. }
  104. for (Books c : vectorBooks) {
  105. cout << "Sales for book " << c.title << endl;
  106. cout << setw(10) << left << "Month 1" << setw(10) << left << "Month 2" << setw(10) << left << "Month 3" << endl;
  107. cout << setw(10) << left << c.sales << setw(10) << left << c.sales1 << setw(10) << left << c.sales2 << endl << endl;
  108. }
  109. system("pause");
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment