Help me please! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help me please!

import java.util.Scanner; abstract class Shape { int width; abstract void area(); } //введите код сюда public class Square extends Shape{ public Square (int x){ width =x; } void area (){ if(width >=0) System.out.println(width *width); } } public class Circle extends Shape { public Circle (int y){ width =y; } void area (){ if (width >=0) System.out.println (width* width* Math.PI); } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Square a = new Square(x); Circle b = new Circle(y); a.area(); b.area(); } }

8th Aug 2022, 6:14 PM
С Сафронов
С Сафронов - avatar
5 Answers
+ 3
You can link your code like this: Go to Code section, click +, select the programming language, insert your code, save. Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code. This way it is more readable and people can test your code. Please tag the relevant programming language. If it is a sololearn task, please mention course name and task number.
8th Aug 2022, 6:18 PM
Lisa
Lisa - avatar
+ 2
С Сафронов You have to place who want help you in better conditions for help you.... Have you problem with a code? Dont copy it in post, but create it in "Code Playground" and insert it in the post (like Lisa explained) so it can be runned and tested directly. Futhermore you have to be more clear about your problem... Its frustrating for who help try to understand what is your problem (beside copy your code and try it on Playground) when you can explain what is your problem and, like said previously, attach the code on Playground ready to be tested
8th Aug 2022, 9:08 PM
KrOW
KrOW - avatar
0
What do you not like about this code? 🤔
8th Aug 2022, 8:36 PM
Solo
Solo - avatar
0
Project 55 Java, not complete secrets test 3
8th Aug 2022, 11:29 PM
С Сафронов
С Сафронов - avatar
0
The task say nothing about negative values. Could this be a problem? Try to remove the conventions.
9th Aug 2022, 1:20 AM
Solo
Solo - avatar