Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ Consider the following statements: #include #include class Temporary { private: string description; double first; double second; public: Temporary(string = , double = 0.0, double
c++
Consider the following statements:
#include#include class Temporary { private: string description; double first; double second; public: Temporary(string = "", double = 0.0, double = 0.0); void set(string, double, double); double manipulate(); void get(string&, double&, double&); void setDescription(string); void setFirst(double); void setSecond(double); };
- Write the definition of the member function set() so that the instance variables are set according to the parameters.
- Write the definition of the constructor so that it initializes the instance variables using the function set()
- Write the definition of the member function manipulate() that returns a decimal number (double) as follows:
- If the value of description is "rectangle", it returns first * second
- If the value of description is "circle" it returns the area of a circle with radius first
- if the value of description is "cylinder" it returns the volume of a cylinder with radius first and height second. HINT: the volume of a cylinder is simply the area of the circle at the base times the height.
- If the value of description is "sphere" it returns the volume of the sphere with radius first.
- Otherwise it returns -1.0;
To save you googling what the formula for the volume of a sphere is, given the radius of the sphere, it is
V=43r3{"version":"1.1","math":"V = \frac{4}{3} \pi \; r^3"}
HINT:
Given these declarations
struct NameType { string first; string last; }; struct CourseType { string name; int callNum; int credits; int grade; }; struct StudentType { NameType name; double gpa; CourseType course; }; StudentType student;
Write C++ statements to store the following information in student:
- name: Linda Brown
- gpa: 3.78
- course name: Calculus
- course call number: 23827
- course credits: 4
- course grade: A
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started