Menu

[Solved]Java Create Java Class Example Output Would 0 User Inputs Number Circle Area 000 Parameter Q37052108

java

create java class
the example of output would be this:
0 // the user inputs any number here
circle area is 0.00 and parameter is 0.00
5//the user inputs any number here
square area is 25.00 and parameter is 20.00
circle area and square area are not same

I have to create 3 classes
interface calculate{}
abstract class Pg implements compare, calculate {
double length;
}
class circle extends Pg{
}
class square extends Pg{
}

here is my main method
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
       double length;
      
       length = sc.nextDouble();
       Circle c = newCircle(length);
       System.out.printf(“circle area:%.2f.n and perimeter is %.2f.n”, c.getArea(),c.getPerimeter());
      
       length = sc.nextDouble();
       Square s = newSquare(length);
       System.out.printf(“square area:%.2f.n and perimeter is %.2f”, s.getArea(),s.getPerimeter());
      
       if (c.compareTo(s) == 0)
          System.out.println(“circle area and square is same.”);
       else
          System.out.println(“circle area and square area is notsame.”);
      
       sc.close();
}
}

Expert Answer


Answer to java create java class the example of output would be this: 0 // the user inputs any number here circle area is 0.00 and… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *