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.1 Interfaces — capstone: one contract, two classes

Write a complete program with an interface Shape declaring area() and name(), and two classes implementing it: Square and Rect.

Read a square side, then a rectangle width and height. Put both shapes in one Shape[] array, print name area for each, then print the total area.

For the input 3 2 5:

Square 9.0
Rect 10.0
19.0
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…