Home > Back-end >  Java small white, request to help with static static reference
Java small white, request to help with static static reference

Time:10-04

Public class work01 {
Public static void main (String [] args) {
Double r, w, h.
Scanner SCN=new Scanner (System. In);
R=the SCN. NextDouble ();
W=SCN. NextDouble ();
H=the SCN. NextDouble ();
C=new MyCircle MyCircle (" circle ", r);
MyRectangle rec=new MyRectangle (" rectangle ", w, h);
C.d raw ();
System. Out. Println (" Area="+ String format (be sad etArea chtistina georgina rossetti.british poetess. % 2 f, ()));
Rec. The draw ();
System. Out. Println (" Area="+ String format (. % 2 f, rec. GetArea ()));
}
The class MyCircle {
Double r;
The String word;
Public MyCircle (String word, double r) {
This. R=r;
This. The word=word;
}
Void the draw () {
System. The out. Println (" great circle: r="+ r);
}
Double getArea () {
Return r * 3.1416;
}
}
The class MyRectangle {
Double w, h;
String appearance;
Public MyRectangle (String appearance, double w, double h) {
Enclosing the appearance=appearance;
This. W=w;
This. H=h;
}
Void the draw () {
System. The out. Println (" rectangle: w="+ w +", h="+ h);
}
Double getArea () {
Return w * h.
}
}
}

CodePudding user response:

Have to solve the problem

CodePudding user response:

Curly braces have the wrong number, took out two classes with respect to OK
  • Related