Question
81. What is the output of the following program? #include using namespace std; class Car { public: double get_speed() const; Car(); Car(double dspeed); private: double
81. What is the output of the following program?
#includeusing namespace std; class Car { public: double get_speed() const; Car(); Car(double dspeed); private: double speed; }; Car::Car() { speed = 0; } Car::Car(double dspeed) { speed = dspeed; } double Car::get_speed() const { return speed; } int main() { Car c1; Car c2(5); double sum_speed = 0; sum_speed = c1.get_speed() + c2.get_speed(); cout << sum_speed << endl; return 0; }
Group of answer choices
5
The answer cannot be determined because the speed of c1 has not been initialized.
0
Nothing is printed because the program doesn't compile.
84. Examine the following code snippet.
class Product { public: Product(); Product(double price); Product(string d_description); Product(string d_description, double price); void set_price(double price); void set_description(string d_description); string get_description() const; void display_product() const; private: string description; double product_price; }; class SalesOrder { public: SalesOrder(string customer_name, string d_description, double price); void display_sales_order() const; private: Product prdt; string customer; }; class RetailShop { public: RetailShop(); void set_sales_order(SalesOrder new_SalesOrder); SalesOrder get_sales_order(); private: SalesOrder sales_order; };
Which of the following statements is correct?
Group of answer choices
The Product class aggregates the SalesOrder class.
The Product class aggregates the RetailShop class.
The SalesOrder class aggregates the RetailShop class.
The SalesOrder class aggregates the Product class.
92. You are given the class definition for CashRegister. One of the member functions of this class is get_total(), which returns a double that represents the register total for the object. Furthermore, you have set up and allocated an array of CashRegisterobjects. Given the declaration of the array all_registers below, which code snippet correctly calls the get_total() function on every object in the all_registers array and uses it to calculate the largest total over all registers (the maximum value of all individual register totals)?
CashRegister all_registers[20];
Group of answer choices
double result = 0.0; for (int i = 0; i < 20; i++) { if (all_registers[i].get_total() > result) { result = all_registers[i]->get_total(); } }
double result = 0.0; for (int i = 0; i < 20; i++) { result += all_registers[i].get_total(); }
double result = 0.0; for (int i = 0; i < 20; i++) { result += all_registers[i]->get_total(); }
double result = 0.0; for (int i = 0; i < 20; i++) { if (all_registers[i].get_total() > result) { result = all_registers[i].get_total(); } }
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