Diesel engine specifications include its weight ( w ), maximum horsepower ( hp )
ID: 3621297 • Letter: D
Question
Diesel engine specifications include its weight ( w ), maximum horsepower ( hp ), and maximum torque ( t ). The performance of such engines can be compared using a performance index. In one study the performance index ( pi ) is defined as the ratio of maximum horsepower per unit of weight (i.e. pi = hp / w ) of engine. Write a program to calculate the performance index of several engines based on the following guidelines.Define a class (called engine ) containing the specifications of a typical engine (i.e. w , hp , and t ) and member function(s) to read these specifications.
Write a program to make use of an object of class engine type to calculate the performance index of six different engines listed below and print the index and the specifications of each engine to an output file having a format exactly like that shown below
Maxium(hp): 68, 72, 168, 725, 220, 130
Maximm torque(Ib-ft): 225, 281, 664, 2840, 560, 393
Weight(Ib): 4750, 5012, 7240, 9680, 7540, 6180
Performance Index(hp/Ib): 0.01431, -------,-------,-------,-------,-------
Explanation / Answer
Hope this helps. Please rate. :) #include using namespace std; class engine { private: double w; double hp; double t; public: double getWeight() { return w; } double getHP() { return hp; } double getTorque() { return t; } double getPI() { return (hp / w); } engine(double weight, double hp, double torque) { this->w = weight; this->hp = hp; this->t = torque; } }; void sendToFile(engine * engines[]) { ofstream fout("myOutput.txt"); foutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.