CJCoding With Joseph
15free / daySign inCreate account

Create a class Rectangle with private double width and double height.

Requirements: 1. Constructor Rectangle(double w, double h): if either w or h is less than or equal to 0, throw a std::invalid_argument with the message "Dimensions must be positive". Otherwise assign them to the fields. 2. double area() const: returns width * height

Do NOT write a main function.

Expected output

50

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
ClassesExceptions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.