Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <sstream>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- char quit = 'c';
- int tempwc = 0;
- int tempwoc = 0;
- do
- {
- string dnum;
- cout << "Enter Design Number: ";
- cin >> dnum;
- cout << endl;
- int numbercolors = 0;
- vector<string> colorvec;
- cout << "Enter Colors(Separated by comma): ";
- string colors;
- cin.ignore();
- getline(cin, colors);
- stringstream sscolors(colors);
- string color;
- while(getline(sscolors, color, ','))
- {
- colorvec.push_back(color);
- numbercolors++;
- }
- cout << endl;
- int numbersizes = 0;
- vector<string> sizevec;
- cout << "Enter Sizes(Separated by comma): ";
- string sizes;
- getline(cin, sizes);
- stringstream sssizes(sizes);
- string size;
- while(getline(sssizes, size, ','))
- {
- sizevec.push_back(size);
- numbersizes++;
- }
- cout << endl;
- int ourprice;
- cout << "Enter Our Price: ";
- cin >> ourprice;
- cout << endl;
- int actprice;
- cout << "Enter Actual Price: ";
- cin >> actprice;
- cout << endl;
- ofstream out;
- if(numbercolors == 0)
- {
- if(tempwoc == 0)
- {
- out.open("w0Color.csv");
- tempwoc++;
- }
- else
- {
- out.open("w0Color.csv", ios::out | ios::app);
- }
- for(int j = 0; j < numbersizes; j++)
- {
- string sizeE;
- sizeE = sizevec[j];
- int random = rand() % 10000000;
- out << dnum << "," << sizeE << "," << random << ourprice << "," << actprice << endl;
- out << dnum << "," << sizeE << "," << random << ourprice << "," << actprice << endl;
- }
- }
- else
- {
- if(tempwc == 0)
- {
- out.open("wColor.csv");
- tempwc++;
- }
- else
- {
- out.open("wColor.csv", ios::out | ios::app);
- }
- for(int i = 0; i < numbercolors; i++)
- {
- string colorE;
- colorE = colorvec[i];
- for(int j = 0; j < numbersizes; j++)
- {
- string sizeE;
- sizeE = sizevec[j];
- int random = rand() % 10000000;
- out << dnum << "," << colorE << "," << sizeE << "," << random << ourprice << "," << actprice << endl;
- out << dnum << "," << colorE << "," << sizeE << "," << random << ourprice << "," << actprice << endl;
- }
- }
- }
- out.close();
- cout<<"Enter q to quit or any key to continue: ";
- cin>>quit;
- }while(quit != 'q');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement