Want more features on Pastebin? Sign Up, it's FREE!
Guest

cpp

By: a guest on Feb 6th, 2013  |  syntax: None  |  size: 1.50 KB  |  views: 2  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. #include "pa1functions.h"
  5.  
  6. void pa1functions::greetUser()
  7. {
  8.     using std::cout;
  9.     using std::cin;
  10.     cout << "Blah\n";
  11.     cin.ignore();
  12.     cout << std::endl;
  13. }
  14.  
  15. int pa1functions::errorChecking(char *fishingFile)
  16. {
  17.  
  18.     if(!fishingFile)
  19.     {
  20.         std::cerr << "Couldn't open file\n";
  21.         return EXIT_FAILURE;
  22.     }
  23. }
  24.  
  25. int pa1functions::findFileSize(int counter, char *fishingFile)
  26. {
  27.     std::ifstream file(fishingFile);
  28.     double placeholder = 0;
  29.     do
  30.     {
  31.         file >> placeholder;
  32.         counter++;
  33.     } while(!file.eof());
  34.     std::cout << counter << std::endl;
  35.     return counter;
  36. }
  37.  
  38. void pa1functions::get(double *yvalues, int counter, char *fishingFile)
  39. {
  40.     std::ifstream file(fishingFile);
  41.     std::cout << "Running get function.\n";
  42.     int number;
  43.     do
  44.     {
  45.         file >> yvalues[number];
  46.         number++;
  47.     }while(!file.eof());
  48. }
  49. int pa1functions::findVolume(double *yvalues, int counter, char *fishingFile)
  50. {
  51.     std::ifstream file(fishingFile);
  52.     std::cout << yvalues[1] << std::endl;
  53.     int area;
  54.     int volume;
  55.     const int depth = 20;
  56.  
  57.     area = yvalues[0] + yvalues[counter];
  58.     for(int i = 1; i < counter; ++++i)
  59.     {
  60.         area += 4 * yvalues[i];
  61.     }
  62.     for(int i = 2; i < counter; ++++i)
  63.     {
  64.         area += 2 * yvalues[i];    
  65.     }
  66.     area = area * 200/3;
  67.     std::cout<<area<<std::endl;
  68.     volume = area * depth;
  69.  
  70.     return volume;
  71. }
clone this paste RAW Paste Data