Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Class and stuff
- // Class Drill for Drill Object
- #include <iostream>
- using namespace std;
- const double PI = 3.142;
- class Drill {
- public:
- Drill () {}
- Drill (double,double,double);
- double mrr() const;
- double torque (double) const;
- private:
- double diameter,
- feed,
- speed;
- friend istream& operator >> (istream&, Drill&);
- friend ostream& operator << (ostream&, const Drill&);
- };
- //
- // Constructor 2: Initializes all components
- //
- Drill::Drill(double drillDiam, double drillFeed, double drillSpeed)
- {
- diameter = drillDiam;
- feed = drillFeed;
- speed = drillSpeed;
- }
- //
- // material removal rate: mm^3/sec
- //
- double Drill :: mrr() const
- {
- return (PI*0.25*diameter*diameter*feed*speed/60.0);
- }
- //
- // torque (W.s) on drill based on unit power (W.s/mm^3)
- // dissipated
- // in cutting workpiece material
- //
- double Drill :: torque (double unitPower) const
- {
- double radSec; // rotational speed in radians per second
- radSec = speed*2*PI/60.0;
- return (unitPower*mrr()/radSec);
- }
- //
- // Extract from input source the three components of a Drill object
- //
- istream& operator >> (istream& is, Drill& dr)
- {
- is >> dr.diameter >> dr.feed >> dr.speed;
- return is;
- }
- //
- // Display a drill object, labeling all components
- //
- ostream& operator << (ostream& os, const Drill& dr)
- {
- os << "Drill " << endl << " diameter: " << dr.diameter << " mm" <<endl
- <<" feed: " << dr.feed << " mm/rev" << endl << " speed: " << dr.speed << " rpm" << endl;
- return os;
- }
- //
- // Driver to declare and manipulate a drill object
- //
- int main ()
- {
- Drill drillA;
- double unitPower;
- cout << "Describe a drill by entering diameter (mm), feed (mm/rev). "
- << "speed (rpm) " << endl << "=>";
- cin >> drillA;
- cout << "Enter average power unit for workpiece material (W.s/mm^3)"
- <<endl << "=>";
- cin>>unitPower;
- cout << endl << drillA << endl;
- cout << "Drill's material removal rate is: " <<
- drillA.mrr() <<
- " mm^3/sec" << endl;
- cout << "Torque on the drill when drilling the given workpiece material: "
- << drillA.torque(unitPower) << "W.s" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement