4 of 5
10
Paper No: 1
0
Question 4:
(2 marks)
The given Q4.cpp file contains statements about input and output data of objects from the
Speaker class. You should write the statements to complete the Speaker class as described
below:
Speaker
Where:
-id: int
- brand: string
power: double
+Speaker(id:int, brand:string, power:double)
+getPowerLevel():double
+changeVolume(percent:int):void
+printInfo():void
• Speaker(id:int,
brand:string,
power:double) constructor, which
sets values to id, brand, and power
return

getPowerLevel():double
the power

changeVolume(int percent): void -
increases or decreases the current
power by a percentage. Formula:
power power *(1+ percent/100)
- For example, if the current power is
200 and change Volume(10) is called,
the new power becomes 220.
If change Volume(-10) is called, the
new power becomes 180.
Zoom
- FUO
+ 100%
Close