ENGN 38

Lab Programming Assignment #9

 

 

Problem: 

A file contains data on an internal combustion engine. 

The data includes pressure vs. volume data sets for one cycle of the engine. 

(See the input file below.)

Your program determines the maximum pressure, minimum pressure, average pressure and compression ratio for the cycle.

 

Programming Requirements:

  1. Use a class/object approach.
    Define a class called enginePerformance.
    Use the class definition shown below. You should add the preconditions and postconditions for the member functions.
                                         

  2. Your program should prompt the user for a file name from which to read the data.
    The file will have the following data. (See the input file below):          

    Data Title                     -- string data
    Engine Identification     -- string data
    Date Performed           -- string data
    Engine speed               -- double variable
    pressure and volume    -- parallel double arrays

                 

  3. Your program should compute the maximum pressure, minimum pressure and average pressure in the cylinder for one cycle.
                     

  4. Your program should  compute the maximum and minimum volume for one cycle and from this compute the compression ratio.
    (Compression ratio = maximum volume/ minimum volume)
                         

  5. Your program should write all the information in a nicely formatted report to a file called "EngineReport.txt".
    (See below for formatting requirements.)

To turn in:            

Print out your source code and program output making sure that the formatting is up to C++ standards and professional in appearance.  If this does not fit on one page, delete enough so that it does. (Please do not make font size less than 10 points.) What to delete? What to keep? Make sure that you at least have the header as shown in Lab#1 (your student number, your name, the class identifier, the lab number) and the output from your program. As space permits, include any other essentials as you deem appropriate. Make sure that everything is clearly labeled and easy to read and follow. Have this one page ready to turn in by the due date. 

                        

Definition of the class enginePerformance:

class enginePerformance
{
public:
      void retreiveData();
           
      void setMaxPressure();
      void setMinPressure();
      void setAveragePressure();
      void setCompressionRatio();
      void outputReport ();     

 string getDataTitle(); 
      string getEngineID();
      string getDate();
 
      double getRPM();
      double getCompRatio();
      double getMaxPressure();
      double getMinPressure();
      double getAveragePressure();
 
private:
      string dataTitle;
      string engineID;
      string date;
 
      double RPM;
      double pressure[SIZE];
      double volume[SIZE];
      int    dataCount;
 
      double compressionRatio;
      double maxPressure;
      double minPressure;
      double averagePressure;
 
      ifstream inputData;
      ofstream report;
 
      void openInputFile ();
      void closeInputFile ();
      void openOutputFile ();
      void closeOutputFile ();
      void clearText ();
};

 

 

 

Definitions and Formulas:                 

          Compression Ratio CR =  maxVolume / minVolume

 

          RPM  =  revolutions per minute

 

          Data Units

              Pressure, P = lb/in2  = psi

              Volume, V =  cubic inches = in3

 

 


Data in input file:

Engine Analysis

Megatech Mark III Model TE1   Serial Number 155

January 10, 2010

1800.           Engine RPM

Cylinder Pressure (psi) , Cylinder Volume (in3)

49       1.52     

65       1.38

87       1.46

122      1.56

98       1.72

64       2.16

45       2.71

34       3.33

28.5     3.94

25       4.5

23       4.95

17       5.27

13       5.46

12       5.49

12.5    5.49

13       5.36

14.5     5.08

15        4.68

15.5     4.15

15.5     3.56

16        2.90

16       2.33

16       1.85

16       1.52

16       1.38

15       1.44

15       1.71

13.5    2.17

13       2.73

12       3.34

12       3.94

12       4.50

12.5    4.95

13       5.27

14       5.46

15       5.50

16       5.36

16.5    5.08

19       4.67

22       4.15

25       3.56

32       2.90

37       2.33

44       1.85

47       1.52

49       1.52

 

 

 

The file "EngineReport.txt" should look like this:

 

Engine Analysis Report

 

Engine ID:  Megatech Mark III Model TE1   Serial Number 155

 

Analysis Date:  January 10, 2010

 

Engine Performance:          Speed                          xxxx   (RPM)

 

                                         Compression Ratio       x.x :  1

 

                                         Pressures

                                                  Maximum             xx.x    (psi)

                                                  Minimum              xx.x    (psi)

                                                  Average               xx.x    (psi)