You are on page 1of 6

#include<iostream>

#include<fstream>

#include<string>

using namespace std;

class Data

public:

int motor[4][5];

string check;

float temp,eff,vib,health;

int stoi(string number)

int integer=0;

int temp;

for(int i=0;i<number.length();i++)

temp = number[i]-'0';

integer = (integer*10)+temp;

return integer;

}
float num(int num)

string junk;

ifstream file;

file.open("Exam.txt");

for(int i=0;i<num;i++)

getline(file,junk);

file>>check;

for(int j=0;j<4;j++)

for(int i=0;i<5;i++)

motor[j][i] = stoi(check);

file>>check;

return motor[4][5];

float average(int array[],int size)

float average_num=0;
int temp=0;

for(int i=0;i<size;i++)

temp=temp + array[i];

average_num=temp/float(size);

return average_num;

float avg_eff()

int array[4]={0};

for(int i=0;i<4;i++)

array[i]=motor[i][4];

eff=average(array,4);

int safe()

cout<<"Motor is working safely at : "<<endl;

for(int i=0;i<4;i++)

if( motor[i][1] <= 1600 && motor[i][1] >= 1400 )


{

if(motor[i][2] <= 60 && motor[i][2] >= 50)

if(motor[i][3] <= 33 && motor[i][3] >= 27)

cout<<"At Date : "<<motor[i][0]<<" March"<<endl;

cout<<endl;

return 0;

float health_score()

int array1[4]={0};

int array2[4]={0};

for(int i=0;i<4;i++)

array1[i]=motor[i][2];

array2[i]=motor[i][3];

}
temp=average(array1,4);

vib=average(array2,4);

health = 2*eff-temp-vib;

return health;

bool compare(Data t)

if(t.health < health)

return true;

else

return false;

bool comp(Data s)

if(s.eff < eff)

return true;

else
{

return false;

void summary()

cout<<"Health score of motor is : "<<health<<endl;

cout<<"Average Efficiency of motor is : "<<eff<<endl;

};

You might also like