fork(1) download
  1. /* package whatever; // don't place package name! */
  2. import java.util.*;
  3. public class Main
  4. {
  5. public static void main(String args[])
  6. {
  7. Shape sh[]=new Shape[5];
  8. Scanner sc=new Scanner(System.in);
  9. for(int i=0; i<5; i++){
  10. String type=sc.nextLine();
  11. if(type.equals("Triangle")){
  12. Triangle t=new Triangle();
  13. t.setBase(Double.parseDouble(sc.nextLine()));
  14. t.setHeight(Double.parseDouble(sc.nextLine()));
  15. sh[i]=t;
  16. }
  17. else if(type.equals("Rectangle")){
  18. r.setLength(Double.parseDouble(sc.nextLine()));
  19. r.setWidth(Double.parseDouble(sc.nextLine()));
  20. sh[i]=r;
  21. }
  22. else if(type.equals("Cube")){
  23. Cube c=new Cube();
  24. c.setLength(Double.parseDouble(sc.nextLine()));
  25. c.setWidth(Double.parseDouble(sc.nextLine()));
  26. c.setHeight(Double.parseDouble(sc.nextLine()));
  27. sh[i]=c;
  28. }
  29. else{
  30. Sphere s=new Sphere();
  31. s.setRadius(Double.parseDouble(sc.nextLine()));
  32. sh[i]=s;
  33. }
  34. }
  35.  
  36. for(int j=0; j<5; j++){
  37. System.out.println("Area" +sh[j].area());
  38. if(sh[j].volume()>0){
  39. System.out.println("Volume" +sh[j].volume());
  40. }
  41. }
  42. }
  43. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:7: error: cannot find symbol
        Shape sh[]=new Shape[5];
        ^
  symbol:   class Shape
  location: class Main
Main.java:7: error: cannot find symbol
        Shape sh[]=new Shape[5];
                       ^
  symbol:   class Shape
  location: class Main
Main.java:12: error: cannot find symbol
                Triangle t=new Triangle();
                ^
  symbol:   class Triangle
  location: class Main
Main.java:12: error: cannot find symbol
                Triangle t=new Triangle();
                               ^
  symbol:   class Triangle
  location: class Main
Main.java:18: error: cannot find symbol
                Rectangle r=new Rectangle();
                ^
  symbol:   class Rectangle
  location: class Main
Main.java:18: error: cannot find symbol
                Rectangle r=new Rectangle();
                                ^
  symbol:   class Rectangle
  location: class Main
Main.java:24: error: cannot find symbol
                Cube c=new Cube();
                ^
  symbol:   class Cube
  location: class Main
Main.java:24: error: cannot find symbol
                Cube c=new Cube();
                           ^
  symbol:   class Cube
  location: class Main
Main.java:31: error: cannot find symbol
                Sphere s=new Sphere();
                ^
  symbol:   class Sphere
  location: class Main
Main.java:31: error: cannot find symbol
                Sphere s=new Sphere();
                             ^
  symbol:   class Sphere
  location: class Main
10 errors
stdout
Standard output is empty