Advertisement
Guest User

SaleS Update 3.3.3

a guest
Feb 9th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.80 KB | None | 0 0
  1. /*
  2. sales.cpp
  3. 2/8/2016, 3.3.3
  4. Steven Piper, Jordan Prokop, Jesse Winter
  5. */
  6. #include <iostream>
  7. #include <stdlib.h>
  8. #include <fstream>
  9. #include <iomanip>
  10. #include <cmath>
  11. #include <string>
  12. #include <assert.h>
  13. using namespace std;
  14.  
  15. //conversion rates. Used by convertUSD function
  16. double const USD = 1.0;
  17. double const CAD = 1.39;
  18. double const BTC = 0.002664;
  19. double const GBP = 0.69;
  20.  
  21.  
  22. //this changes the amount of asterisks shown. Only supported for USD
  23. int const BAR_GRAPH_SCALE = 3500;
  24.  
  25. char const CURR_SIGN_USD = '$';
  26. string const CURR_SIGN_BTC = "BTC";
  27. char const CURR_SIGN_CAD = '$';
  28. string const CURR_SIGN_GBP = "GBP";
  29.  
  30. //prototypes
  31. void welcomeScreen();
  32. char getMenuSelection();
  33. void menuExec(char control);
  34. int charToInt(char var);
  35. int getOptionSelection();
  36. void options();
  37. void add();
  38. void optionMenuExec(int selection);
  39. void view();
  40. void genDefConfig();
  41. void loadOptions();
  42. void changeOptions(int transferArray);
  43. void convertUSD();
  44. void deleteAllFiles();
  45. void convertUSDConfig();
  46. int getConvertUSDConfigSelection();
  47. void configUSD();
  48. void configCAD();
  49. void configBTC();
  50. void configGBP();
  51. string getSign();
  52.  
  53. int main()
  54. {
  55.     //Generates config if one doesnt exist
  56.     genDefConfig();
  57.     //loads config
  58.     loadOptions();
  59.  
  60.     //Greets user
  61.     welcomeScreen();
  62.     do
  63.     {
  64.         //sets selection to what the user enters, after being prompted
  65.         char selection = getMenuSelection();
  66.  
  67.         //uses what the user enters in, to be ran through the switch statement
  68.         menuExec(selection);
  69.     //will continue to repeat until user exits
  70.     } while (1>0);
  71.  
  72.     system("pause");
  73.     return 0;
  74. }
  75.  
  76. /*************************************************
  77. Function: welcomeScreen
  78. Description:Greets the user
  79. Input: no input
  80. Precondition: no precondition
  81. Postcondition: prints out a greeting before returning
  82. *************************************************/
  83. void welcomeScreen()
  84. {
  85.     cout << "Welcome to the SaleS!\n\n";
  86.     return;
  87. }
  88.  
  89. /*************************************************
  90. Function:getMenuSelection
  91. Description: This will prompt the user with menu options
  92. Input: a single number char value
  93. Precondition: user input must be valid
  94. Postcondition: Returns selection, char value between 1-3, and char X
  95. *************************************************/
  96. char getMenuSelection()
  97. {
  98.     char selection = ' ';
  99.     do
  100.     {
  101.         //prompt
  102.         cout.setf(ios::left);
  103.         cout << setw(40) << "What would you like to do?" << endl;
  104.         cout << setw(40) << "|Add a sales record" << setw(10) << "| 1" << endl;
  105.         cout << setw(40) << "|View a sales record" << setw(10) << "| 2" << endl;
  106.         cout << setw(40) << "|Options" << setw(10) << "| 3" << endl;
  107.         cout << setw(40) << "|Exit" << setw(10) << "| X" << endl;
  108.         cout << "-->|";
  109.         cin >> selection;
  110.         cout << endl;
  111.     }
  112.     //If an invalid char is entered, it will repeat. This allows for functions to not worry about values out of bounds
  113.     while (!(selection == '1' || selection == '2' || selection == '3' || selection == 'X' || selection == 'x'));
  114.  
  115.     return selection;
  116. }
  117.  
  118. /*************************************************
  119. Function: menuExec
  120. Description: This takes the char control, that the user entered, and runs it through a switch statement to carry out an action
  121. Input: char control
  122. Precondition: char control must be x, X, 1, 2, or 3
  123. Postcondition: Will run what the user selects
  124. *************************************************/
  125. void menuExec(char control)
  126. {
  127.     //converts the char values to int values, for use in switch statement. X = 0
  128.     int controlInt = charToInt(control);
  129.  
  130.  
  131.     //This allows for the switch statement to use Titles instead of numbers
  132.     enum menutitles{ EXIT, ADD, VIEW, OPTIONS };
  133.     switch (controlInt)
  134.     {
  135.     case EXIT:
  136.         exit(1);
  137.         break;
  138.     case ADD:
  139.         add();
  140.         break;
  141.     case VIEW:
  142.         view();
  143.         break;
  144.     case OPTIONS:
  145.         options();
  146.         break;
  147.     }
  148.     return;
  149. }
  150.  
  151. /*************************************************
  152. Function: charToInt
  153. Description: Converts the user input to an int for the switch statement in menuExec
  154. Input: char control
  155. Precondition: char control must be x, X, 1, 2, or 3
  156. Postcondition: Converts 'x'||'X' = 0, '1' = 1, '2' = 2, '3' = 3
  157. *************************************************/
  158. int charToInt(char var)
  159. {
  160.     int control = 0;
  161.     if (var == 'X' || var == 'x')
  162.     {
  163.         control = 0;
  164.     }
  165.     else if (var == '1')
  166.     {
  167.         control = 1;
  168.     }
  169.     else if (var == '2')
  170.     {
  171.         control = 2;
  172.     }
  173.     else if (var == '3')
  174.     {
  175.         control = 3;
  176.     }
  177.     else if (var == '4')
  178.     {
  179.         control = 4;
  180.     }
  181.     return control;
  182. }
  183.  
  184. /*************************************************
  185. Function: view
  186. Description: Shows a graph and currency
  187. Precondition:called when view is selected by user
  188. Postcondition: displays names, currecny and a graph that depends on the constant BAR_GRAPH_SCALE
  189. *************************************************/
  190. void view()
  191. {
  192.     string sign = getSign();
  193.     //Declare stream
  194.     ifstream nameInput;
  195.     ifstream salaryInput;
  196.  
  197.     nameInput.open("names.txt");
  198.     salaryInput.open("sales.txt");
  199.     string name[100];
  200.     double salary[100];
  201.     int index = 0;
  202.  
  203.     do
  204.     {
  205.    
  206.         getline(nameInput, name[index]);
  207.         //runs through converter. Default is USD
  208.         salaryInput >> salary[index];
  209.         index++;
  210.     }
  211.     while (!salaryInput.eof());
  212.  
  213.     nameInput.close();
  214.     salaryInput.close();
  215.     //This is the bar graph. You can change the scale of the graph at the top. BAR_GRAPH_SCALE
  216.     for (int c = 0; c < index - 1; c++)
  217.     {
  218.         //prints out name, cash, and asterisk graph.
  219.         cout << setw(16) << name[c] << " | "  << salary[c] << sign << " ||";
  220.         for (int j = 0; j < salary[c] / BAR_GRAPH_SCALE; j++)
  221.         {
  222.             cout << "*";
  223.         }
  224.         cout << endl;
  225.     }
  226.  
  227.     return;
  228. }
  229.  
  230. /*************************************************
  231. Function: add
  232. Description: adds names and salary to txt
  233. Input: 2 strings and an int
  234. Precondition:called when add is selected by user
  235. Postcondition: adds entries to text
  236. *************************************************/
  237. void add()
  238. {
  239.     //Revised Jesse's function
  240.     //Declare stream
  241.     ofstream nameOutput;
  242.     ofstream salaryUSDOutput;
  243.     ofstream salaryConvertedOutput;
  244.     //Open file SalesStats.txt
  245.     nameOutput.open("names.txt", fstream::app);
  246.     salaryUSDOutput.open("salesUSD.txt", fstream::app);
  247.     salaryConvertedOutput.open("sales.txt", fstream::app);
  248.     //defining Arrays with 100 spaces
  249.     string name[100];
  250.     double salary[100];
  251.  
  252.     int entryAmt = 0;
  253.  
  254.  
  255.     cout << "|How many entries are to be added?\n-->|";
  256.     cin >> entryAmt;
  257.     cout << endl;
  258.     //This loop will store the values in the arrays, and read them out to two seperate files. When read, it should read in the same values at the same index. IE name[6] corresponds to salary[6]
  259.     for (int c = 0; c < entryAmt; c++)
  260.     {
  261.         cout << "Please input first then last name of Salesperson.\n-->|";
  262.         cin.ignore();
  263.         //This allows for a whole line (including whitespaces) to be stored
  264.         getline(cin, name[c]);
  265.         //prints out an end line character
  266.         nameOutput << name[c] << '\n';
  267.         cout << "Please input total sales of Salesperson.\n-->|";
  268.         cin >> salary[c];
  269.         //Stores in two seperate files. This is because salesUSD remains unchanged (except appened), while sales constantly gets overwritten by currency conversions, dependin on the second value in config.txt
  270.         salaryUSDOutput << salary[c] << '\n';
  271.         salaryConvertedOutput << salary[c] << '\n';
  272.         cout << endl;
  273.     }
  274.     nameOutput.close();
  275.     salaryUSDOutput.close();
  276.     salaryConvertedOutput.close();
  277.     //This is to update sales.txt, as non converted values will be added. This will rewrite the whole file
  278.     loadOptions();
  279. }
  280.  
  281. /*************************************************
  282. Function: Option
  283. Description: gets user input for options
  284. Input: char selection
  285. Precondition:must be called before optionMenuExec
  286. Postcondition: calls charToInt, and passes parameter to execOptionMenu
  287. *************************************************/
  288. void options()
  289. {
  290.     int selection = getOptionSelection();
  291.     charToInt(selection);
  292.     optionMenuExec(selection);
  293.     return;
  294. }
  295.  
  296. /*************************************************
  297. Function: loadOptions
  298. Description: This reads config.cfg, to change saved options.
  299. Input: no input
  300. Precondition: reccomended to have a clean config file
  301. Postcondition: changes options to what is saved in config
  302. *************************************************/
  303. void loadOptions()
  304. {
  305.     ifstream readConfig;
  306.     readConfig.open("config.txt");
  307.  
  308.     //DO NOT TOUCH INDEX 0. THAT VALUE MUST STAY -1 FOR THE ENTIRE LIFE OF THIS PROJECT
  309.     int options[4];
  310.     for (int c = 0; c < 4; c++)
  311.     {
  312.         //This saves the config numbers into options array
  313.         readConfig >> options[c];
  314.     }
  315.     readConfig.close();
  316.     convertUSD();
  317.     return;
  318. }
  319.  
  320. /*************************************************
  321. Function: generate Default Config
  322. Description: This will create the default config file when loaded up. This will only create the folder on first run.
  323. Input: no input
  324. Precondition: reccomended to have a clean config file
  325. Postcondition: Creates a default config file, if one does not exist
  326. *************************************************/
  327. void genDefConfig()
  328. {
  329.     ofstream generateDefaultCfg;
  330.     generateDefaultCfg.open("config.txt", ios::app);
  331.     if (generateDefaultCfg.is_open())
  332.     {
  333.         int check = 0;
  334.         ifstream checkFile;
  335.         checkFile.open("config.txt");
  336.         checkFile >> check;
  337.  
  338.         //If the first value is -1, then nothing will be changed.
  339.         if (check != -1)
  340.         {
  341.             //Generates settings
  342.             generateDefaultCfg << "-1" << endl << "1" << endl << "1" << endl << '1';
  343.         }
  344.     }
  345.     generateDefaultCfg.close();
  346.     return;
  347. }
  348.  
  349. /*************************************************
  350. Function: getOptionSelection
  351. Description: gets user input for options
  352. Input: char selection
  353. Precondition:must be called before optionMenuExec
  354. Postcondition: calls charToInt, and passes parameter to execOptionMenu
  355. *************************************************/
  356. int getOptionSelection()
  357. {
  358.     char selection = ' ';
  359.     do
  360.     {
  361.         cout.setf(ios::left);
  362.         cout << setw(40) << "What would you like to do?" << endl;
  363.         cout << setw(40) << "|Change Currency" << setw(10) << "| 1" << endl;
  364.         cout << setw(40) << "|Delete All Files" << setw(10) << "| 2" << endl;
  365.         cout << setw(40) << "|Exit" << setw(10) << "| X" << endl;
  366.         cout << "-->|";
  367.         cin >> selection;
  368.         cout << endl;
  369.     }
  370.     //If an invalid char is entered, it will repeat. This allows for functions to not worry about values out of bounds
  371.     while (!(selection == '1' || selection == '2' || selection == '3' || selection == 'X' || selection == 'x'));
  372.     //converts to int before returning
  373.     int selectionInt = charToInt(selection);
  374.     return selectionInt;
  375. }
  376.  
  377. /*************************************************
  378. Function: optionsMenuExec
  379. Description: Prompts for options
  380. Input: Int selection
  381. Precondition: Must be called
  382. Postcondition: Calls option stuff
  383. *************************************************/
  384. void optionMenuExec(int selection)
  385. {
  386.     enum menutitles{ EXIT, CURR, DELETE };
  387.     switch (selection)
  388.     {
  389.     case EXIT:
  390.         exit(1);
  391.         break;
  392.     case CURR:
  393.         convertUSDConfig();
  394.         break;
  395.     case DELETE:
  396.         string prompt;
  397.         cout << "\n|Are you sure you want to delete all files permanently? Type \"Yes\" to continue.\n-->|";
  398.             cin >> prompt;
  399.             if (prompt == "yes" || prompt == "Yes" || prompt == "yEs" || prompt == "yeS" || prompt == "YEs" || prompt == "YES" || prompt == "YeS")
  400.             {
  401.                 deleteAllFiles();
  402.             }
  403.             else
  404.             {
  405.                 cout << "No files have been deleted. Exiting now.\n";
  406.             }
  407.             system("pause");
  408.         exit(1);
  409.         break;
  410.     }
  411.     return;
  412. }
  413.  
  414. /*************************************************
  415. Function: deleteAllFiles
  416. Description: This deletes all of the txt files
  417. Input: No input
  418. Precondition: Must have existing files to delete
  419. Postcondition: deletes sales.txt, salesUSD.txt, names.txt, and config.txt
  420. *************************************************/
  421. void deleteAllFiles()
  422. {
  423.     //This deletes all created files.
  424.     remove("sales.txt");
  425.     remove("salesUSD.txt");
  426.     remove("names.txt");
  427.     remove("config.txt");
  428.     cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n==========================================\nFiles Deleted.\n==========================================\nExiting.\n";
  429.     system("pause");
  430.     exit(1);
  431.     return;
  432. }
  433.  
  434. /*************************************************
  435. Function: convertUSD
  436. Description: Converts all values in salesUSD.txt, and saves them to sales.txt
  437. Input: all the values from sales.txt
  438. Precondition: Files must contain double values
  439. Postcondition: overwrites sales.txt with conversion numbers
  440. *************************************************/
  441. void convertUSD()
  442. {
  443.     //This array obtains the value of the second number in config
  444.     int currencyOption[2];
  445.     //This reads in the salary amount
  446.     double salary[100];
  447.  
  448.     //Must be -1, or else random numbers will be printed out to sales.txt
  449.     int entries = -1;
  450.  
  451.     //this will read in the first two values of config. The first is irrelevant
  452.     ifstream readCurrencyOption;
  453.     readCurrencyOption.open("config.txt");
  454.     //DO NOT TOUCH INDEX 0. THAT VALUE MUST STAY -1 FOR THE ENTIRE LIFE OF THIS PROJECT
  455.     for (int c = 0; c < 2; c++)
  456.     {
  457.         readCurrencyOption >> currencyOption[c];
  458.     }
  459.     readCurrencyOption.close();
  460.  
  461.     ifstream readSalaries;
  462.     readSalaries.open("salesUSD.txt", ios::app);
  463.    
  464.     int index = 0;
  465.     //This stores the nonconverted USD data into salary[]
  466.     do
  467.     {
  468.         readSalaries >> salary[index];
  469.         entries++;
  470.         index++;
  471.     } while (!readSalaries.eof());
  472.     readSalaries.close();
  473.  
  474.     //this will writeout to sales.txt. This is not appeneded.
  475.     ofstream convertSalaries;
  476.     convertSalaries.open("sales.txt");
  477.     index = 0;
  478.     if (currencyOption[1] == 1)
  479.     {
  480.         for (int c = 0; c < entries; c++)
  481.         {
  482.             convertSalaries << salary[index] * USD << endl;
  483.             index++;
  484.         }
  485.     }
  486.     //Canadian Dollar
  487.     else if (currencyOption[1] == 2)
  488.     {
  489.         for (int c = 0; c < entries; c++)
  490.         {
  491.             convertSalaries << salary[index] * CAD << endl;
  492.             index++;
  493.         }
  494.     }
  495.     //Bitcoin
  496.     else if (currencyOption[1] == 3)
  497.     {
  498.         for (int c = 0; c < entries; c++)
  499.         {
  500.             convertSalaries << salary[index] * BTC << endl;
  501.             index++;
  502.         }
  503.     }
  504.     //British Pound
  505.     else if (currencyOption[1] == 4)
  506.     {
  507.         for (int c = 0; c < entries; c++)
  508.         {
  509.             convertSalaries << salary[index] * GBP << endl;
  510.             index++;
  511.         }
  512.     }
  513.     convertSalaries.close();
  514.     return;
  515. }
  516.  
  517. /*************************************************
  518. Function: convertUSDConfig
  519. Description: A menu to run the different conversions to save to config.txt
  520. Input: user input 1-3 and x||X
  521. Precondition: sales.txt must exist
  522. Postcondition: runs one of the conversion functions
  523. *************************************************/
  524. void convertUSDConfig()
  525. {
  526.     enum currencies{EXIT, USD, CAD, BTC, GBP};
  527.     int control = getConvertUSDConfigSelection();
  528.     switch (control)
  529.     {
  530.     case EXIT:
  531.         exit(1);
  532.         break;
  533.     case USD:
  534.         configUSD();
  535.         break;
  536.     case CAD:
  537.         configCAD();
  538.         break;
  539.     case BTC:
  540.         configBTC();
  541.         break;
  542.     case GBP:
  543.         configGBP();
  544.         break;
  545.     }
  546.     return;
  547. }
  548.  
  549. /*************************************************
  550. Function: getConvertUSDConfigSelection
  551. Description: This prompts the user for a selection, to be returned to convertUSDConfig
  552. Input: user input 1-4 and x||X
  553. Precondition: must be called and set to an int
  554. Postcondition: returns an integer that the user typed in, or 0 if the user entered in x||X
  555. *************************************************/
  556. int getConvertUSDConfigSelection()
  557. {
  558.     char selection = ' ';
  559.     do
  560.     {
  561.         cout.setf(ios::left);
  562.         cout << setw(40) << "Which Currency would you like to use?" << endl;
  563.         cout << setw(40) << "|USD (Default)" << setw(10) << "| 1" << endl;
  564.         cout << setw(40) << "|Canadian Dollar" << setw(10) << "| 2" << endl;
  565.         cout << setw(40) << "|Bitcoin" << setw(10) << "| 3" << endl;
  566.         cout << setw(40) << "|British Pound" << setw(10) << "| 4" << endl;
  567.         cout << setw(40) << "|Exit" << setw(10) << "| X" << endl;
  568.         cout << "-->|";
  569.         cin >> selection;
  570.         cout << endl;
  571.     }
  572.     //If an invalid char is entered, it will repeat. This allows for functions to not worry about values out of bounds
  573.     while (!(selection == '1' || selection == '2' || selection == '3' || selection == '4' || selection == 'X' || selection == 'x'));
  574.     //converts to int before returning
  575.     int selectionInt = charToInt(selection);
  576.     return selectionInt;
  577. }
  578.  
  579. /*************************************************
  580.  
  581. CONFIG CONVERSIONS BELOW
  582.  
  583. Functions: configUSD, configCAD, configBTC, and configGBP
  584. description: overwrites the 2nd value in config.txt, to be read by loadOptions.
  585. US Dollar = 1
  586. Canadian Dollar = 2
  587. Bitcoin = 3
  588. British Pound = 4
  589. *************************************************/
  590. void configUSD()
  591. {
  592.     ofstream editConfig;
  593.     ifstream readConfig;
  594.     readConfig.open("config.txt");
  595.     int options[4];
  596.     for (int c = 0; c < 4; c++)
  597.     {
  598.         //This saves the config numbers into options array. Only index 1 is being touched. The rest are stored, and rewritten.
  599.         readConfig >> options[c];
  600.     }
  601.     readConfig.close();
  602.  
  603.     editConfig.open("config.txt");
  604.     for (int c = 0; c < 4; c++)
  605.     {
  606.         //This rewrites the config, only changing index 1
  607.         if (c != 1)
  608.         {
  609.             editConfig << options[c] << endl;
  610.         }
  611.         else
  612.         {
  613.             //           =USD=
  614.             editConfig << "1" << endl;
  615.         }
  616.     }
  617.     editConfig.close();
  618.     loadOptions();
  619.     return;
  620. }
  621.  
  622. void configCAD()
  623. {
  624.     ofstream editConfig;
  625.     ifstream readConfig;
  626.     readConfig.open("config.txt");
  627.     int options[4];
  628.     for (int c = 0; c < 4; c++)
  629.     {
  630.         //This saves the config numbers into options array. Only index 1 is being touched. The rest are stored, and rewritten.
  631.         readConfig >> options[c];
  632.     }
  633.     readConfig.close();
  634.  
  635.     editConfig.open("config.txt");
  636.     for (int c = 0; c < 4; c++)
  637.     {
  638.         //This rewrites the config, only changing index 1
  639.         if (c != 1)
  640.         {
  641.             editConfig << options[c] << endl;
  642.         }
  643.         else
  644.         {
  645.             //           =CAD=
  646.             editConfig << "2" << endl;
  647.         }
  648.     }
  649.     editConfig.close();
  650.     loadOptions();
  651.     return;
  652. }
  653.  
  654. void configBTC()
  655. {
  656.     ofstream editConfig;
  657.     ifstream readConfig;
  658.     readConfig.open("config.txt");
  659.     int options[4];
  660.     for (int c = 0; c < 4; c++)
  661.     {
  662.         //This saves the config numbers into options array. Only index 1 is being touched. The rest are stored, and rewritten.
  663.         readConfig >> options[c];
  664.     }
  665.     readConfig.close();
  666.  
  667.     editConfig.open("config.txt");
  668.     for (int c = 0; c < 4; c++)
  669.     {
  670.         //This rewrites the config, only changing index 1
  671.         if (c != 1)
  672.         {
  673.             editConfig << options[c] << endl;
  674.         }
  675.         else
  676.         {
  677.             //           =BTC=
  678.             editConfig << "3" << endl;
  679.         }
  680.     }
  681.     editConfig.close();
  682.     loadOptions();
  683.     return;
  684. }
  685.  
  686. void configGBP()
  687. {
  688.     ofstream editConfig;
  689.     ifstream readConfig;
  690.     readConfig.open("config.txt");
  691.     int options[4];
  692.     for (int c = 0; c < 4; c++)
  693.     {
  694.         //This saves the config numbers into options array. Only index 1 is being touched. The rest are stored, and rewritten.
  695.         readConfig >> options[c];
  696.     }
  697.     readConfig.close();
  698.  
  699.     editConfig.open("config.txt");
  700.     for (int c = 0; c < 4; c++)
  701.     {
  702.         //This rewrites the config, only changing index 1
  703.         if (c != 1)
  704.         {
  705.             editConfig << options[c] << endl;
  706.         }
  707.         else
  708.         {
  709.             //           =GBP=
  710.             editConfig << "4" << endl;
  711.         }
  712.     }
  713.     editConfig.close();
  714.     loadOptions();
  715.     return;
  716. }
  717.  
  718. string getSign()
  719. {
  720.     int currencyOption[2];
  721.     ifstream readCurrencyOption;
  722.     readCurrencyOption.open("config.txt");
  723.     //DO NOT TOUCH INDEX 0. THAT VALUE MUST STAY -1 FOR THE ENTIRE LIFE OF THIS PROJECT
  724.     for (int c = 0; c < 2; c++)
  725.     {
  726.         readCurrencyOption >> currencyOption[c];
  727.     }
  728.  
  729.     if (currencyOption[1] == 1)
  730.     {
  731.         return "$";
  732.     }
  733.     else if (currencyOption[1] == 2)
  734.     {
  735.         return "$";
  736.     }
  737.     else if (currencyOption[1] == 3)
  738.     {
  739.         return "BTC";
  740.     }
  741.     else if (currencyOption[1] == 4)
  742.     {
  743.         return "GBP";
  744.     }
  745.     readCurrencyOption.close();
  746. }
  747.  
  748. /*
  749. CODE REUSE
  750.  
  751.  
  752. Read currency option in config
  753. ****************************************************
  754. int currencyOption[2];
  755. ifstream readCurrencyOption;
  756. readCurrencyOption.open("config.txt");
  757. //DO NOT TOUCH INDEX 0. THAT VALUE MUST STAY -1 FOR THE ENTIRE LIFE OF THIS PROJECT
  758. for (int c = 0; c < 2; c++)
  759. {
  760. readCurrencyOption >> currencyOption[c];
  761. }
  762. readCurrencyOption.close();
  763.  
  764. *************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement