0

Shapes project

Can someone give me completed shapes project code? I dont know how to create it and its only project that missing..

30th Nov 2020, 6:28 PM
MartinGames
MartinGames - avatar
2 Respostas
+ 2
import java.util.Scanner; abstract class Shape { int width; abstract void area(); } class Circle { int x; public Circle(int x){this.x=x;} public void area(){ System.out.println(Math.PI*x*x); } } class Square { int x; public Square(int x){this.x=x;} public void area(){ System.out.println(x*x); } } 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(); } }
27th Feb 2022, 8:46 AM
Vaibhav
Vaibhav - avatar