Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <sstream>
  5. #include <stdlib.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. char quit = 'c';
  12. int tempwc = 0;
  13. int tempwoc = 0;
  14. do
  15. {
  16. string dnum;
  17. cout << "Enter Design Number: ";
  18. cin >> dnum;
  19. cout << endl;
  20.  
  21. int numbercolors = 0;
  22. vector<string> colorvec;
  23. cout << "Enter Colors(Separated by comma): ";
  24. string colors;
  25. cin.ignore();
  26. getline(cin, colors);
  27. stringstream sscolors(colors);
  28. string color;
  29. while(getline(sscolors, color, ','))
  30. {
  31. colorvec.push_back(color);
  32. numbercolors++;
  33. }
  34. cout << endl;
  35.  
  36. int numbersizes = 0;
  37. vector<string> sizevec;
  38. cout << "Enter Sizes(Separated by comma): ";
  39. string sizes;
  40. getline(cin, sizes);
  41. stringstream sssizes(sizes);
  42. string size;
  43. while(getline(sssizes, size, ','))
  44. {
  45. sizevec.push_back(size);
  46. numbersizes++;
  47. }
  48. cout << endl;
  49.  
  50. int ourprice;
  51. cout << "Enter Our Price: ";
  52. cin >> ourprice;
  53. cout << endl;
  54.  
  55.  
  56. int actprice;
  57. cout << "Enter Actual Price: ";
  58. cin >> actprice;
  59. cout << endl;
  60.  
  61. ofstream out;
  62. if(numbercolors == 0)
  63. {
  64. if(tempwoc == 0)
  65. {
  66. out.open("w0Color.csv");
  67. tempwoc++;
  68. }
  69. else
  70. {
  71. out.open("w0Color.csv", ios::out | ios::app);
  72. }
  73. for(int j = 0; j < numbersizes; j++)
  74. {
  75. string sizeE;
  76. sizeE = sizevec[j];
  77. int random = rand() % 10000000;
  78. out << dnum << "," << sizeE << "," << random << ourprice << "," << actprice << endl;
  79. out << dnum << "," << sizeE << "," << random << ourprice << "," << actprice << endl;
  80. }
  81. }
  82. else
  83. {
  84. if(tempwc == 0)
  85. {
  86. out.open("wColor.csv");
  87. tempwc++;
  88. }
  89. else
  90. {
  91. out.open("wColor.csv", ios::out | ios::app);
  92. }
  93.  
  94. for(int i = 0; i < numbercolors; i++)
  95. {
  96. string colorE;
  97. colorE = colorvec[i];
  98. for(int j = 0; j < numbersizes; j++)
  99. {
  100. string sizeE;
  101. sizeE = sizevec[j];
  102. int random = rand() % 10000000;
  103. out << dnum << "," << colorE << "," << sizeE << "," << random << ourprice << "," << actprice << endl;
  104. out << dnum << "," << colorE << "," << sizeE << "," << random << ourprice << "," << actprice << endl;
  105. }
  106. }
  107. }
  108.  
  109. out.close();
  110. cout<<"Enter q to quit or any key to continue: ";
  111. cin>>quit;
  112. }while(quit != 'q');
  113. return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement