6. Demonstrate a working knowledge of computer usage, including knowledge of one
ID: 3842042 • Letter: 6
Question
6. Demonstrate a working knowledge of computer usage, including knowledge of one or more computer languages or documentation of the use of one or more computer software packages for technical problem solving appropriate to the electrical engineering technology discipline. Performance Indicators: • Provide documentation-including some source code – showing software the student has written using a high-level language such as Fortran, C, C++, or Java. • Identify the problem the student solved. • Discuss the rationale for choosing the software. • Discuss how a computer software package was used to solve a particular problem. • Identify issues that arose and their resolution.
Explanation / Answer
#include <iostream> // using IO functions
#include <string> // using string
using namespace std;
class Circle {
private:
double radius; // Data member (Variable)
string color; // Data member (Variable)
public:
Circle(double r = 1.0, string c = "red") {
radius = r;
color = c;
}
double getRadius() { // Member function (Getter)
return radius;
}
string getColor() { // Member function (Getter)
return color;
}
double getArea() { // Member function
return radius*radius*3.1416;
}
};
// Test driver function
int main() {
Circle c1(1.2, "blue");
cout << "Radius=" << c1.getRadius() << " Area=" << c1.getArea()
<< " Color=" << c1.getColor() << endl;
Circle c2(3.4); // default color
cout << "Radius=" << c2.getRadius() << " Area=" << c2.getArea()
<< " Color=" << c2.getColor() << endl;
Circle c3; // default radius and color
cout << "Radius=" << c3.getRadius() << " Area=" << c3.getArea()
<< " Color=" << c3.getColor() << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.