Home > Back-end >  Ask god help children! Look at the code where the problem (running the location of the red words dis
Ask god help children! Look at the code where the problem (running the location of the red words dis

Time:03-17

Package make;

import java.util.Scanner;

The class MyException extends Exception {
Public MyException () {
super();
}
Public MyException (String message) {
Super (message);
}
}
The class My {
Public void play (int a, b int, int) c throws MyException {
If (a + bThrow new MyException (" cannot constitute a triangle ");
}
System. The out. Println (" can constitute a triangle ");
}
}
Public class Trangle {
The static double a, b, c;
Private static Scanner scan;
Public Trangle ()
{

}
Public double getCircle ()
{
The return of a + b + c;
}
Public double getArea ()
{
Double p=(a + b + c)/2.0;
Double s=math.h SQRT (p * (p - a) * (p - b) * (p - c));
return s;
}
Public static void main (String [] args) throws MyException {
Try {
Trangle S=new Trangle ();
for(int i=0; i<1) {
System. The out. Println (" input triangle three side: ");
Scan=new Scanner (System. In);
A=scan. NextDouble ();
B=scan. NextDouble ();
C=scan. NextDouble ();
}
} the catch ( MyException e) {
System. The out. Println (" exception: "+ e. oString ());
System. The out. Println (um participant etMessage ());
}

}

}
  • Related