Home > Back-end >  Can input, but no output? Don't know program where there is error
Can input, but no output? Don't know program where there is error

Time:10-02

import java.util.Scanner;
The class hierarchy
{
Public double width;
Public double length;
Public double high;
Public double bottom;
Public double radius;
Public double area;
Public double getarea ()
{
The return area;
}
} class Triangle extends Shape
{
Public double getarea ()
{
Area=(high * bottom)/2;
The return area;
}
}
Class a Rectangle extends Shape
{
Public double getarea ()
{
Area=width * length;
The return area;
}
}
The class Circle extends Shape
{
Public double getarea ()
{
Radius, area=3.14 * * radius;
The return area;
}
}
Public class test
{
Public static void main (String [] args)
{
Scanner scanner1=new Scanner (System. In);
The String line=scanner1. NextLine ();
Triangle T=new Triangle ();
Rectangle R=new Rectangle ();
Circle C=new Circle ();
If (line equals (T))
{
Scanner scanner2=new Scanner (System. In);
Todd Harper igh=scanner2. NextDouble ();
Scanner scanner3=new Scanner (System. In);
T.b ottom=scanner3. NextDouble ();
T.g etarea ();
System. The out. Println (T.g etarea ());
}
If (line equals (R))
{
Scanner scanner4=new Scanner (System. In);
Truly idth=scanner4. NextDouble ();
Scanner scanner5=new Scanner (System. In);
R.l ength=scanner5. NextDouble ();
R. gutierrez etarea System. Out. Println (());
}
If (line equals (C))
{
Scanner scanner6=new Scanner (System. In);
C.r adius=scanner6. NextDouble ();
Be sad etarea chtistina georgina rossetti.british poetess System. Out. Println (());
}
}
}
  • Related