Task 7 of 7 · 0 solved · 7 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

Problem

8.3 Abstract classes — capstone: shared describe

Write a complete program with an abstract class Shape that holds the name, declares abstract double area(), and has a finished describe() using that area.

Add Square and Triangle subclasses supplying only area(). Read the square side, then the triangle base and height, and print the description of each.

For the input 3 4 6:

Square has area 9.0
Triangle has area 12.0

Note that describe() is written once in the abstract class, yet it calls each subclass's own area().

time 1000 ms memory 256 Mb
Solution
Attempts: 0 A hint guides you to the fix — it never writes the code for you.
✦
Ready to check

Press «Submit» to run your code against the task's test cases — that is what sets your score. «AI review» is an optional second opinion: it reads your code — logic and style, not just the output — and suggests the next step without handing over the answer. It never changes your score.

Next module →
Working…