fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.lang.Math.*;
  5.  
  6. class Student{
  7. int H;
  8. int W;
  9. float BMI;
  10.  
  11. Student(){ //3
  12. this("Jack",180,68);
  13. //H=180;
  14. //W=68;
  15. //Name="Jack";
  16. }
  17.  
  18. Student(int H,int W){ //1
  19. this.H=H;
  20. this.W=W;
  21. }
  22. Student(String Name,int H,int W){ //2
  23. this(H,W);
  24. this.Name=Name;
  25. //this.H=H;
  26. //this.W=W;
  27. }
  28. void setName(String Name){
  29. this.Name=Name;
  30. }
  31. void show(){
  32. System.out.println("學生:"+Name+",身高:"+H+"公分,體重:"+W+"公斤,BMI:"+BMI);
  33. }
  34. void calculate(){
  35. BMI=W/((H/100.0f)*(H/100.0f));
  36. }
  37. void toCompare(Student s){
  38. if((H+W)>(s.H+s.W)){
  39. System.out.println(Name+"與"+s.Name+"相差"+(H-s.H)+"公分及"+(W-s.W)+"公斤");
  40. }
  41. else{
  42. System.out.println(Math.abs)(Name+"與"+s.Name+"相差"+(s.H-H)+"公分及"+(s.W-W)+"公斤");
  43. }
  44.  
  45. }
  46. }
  47.  
  48.  
  49.  
  50. class Ideone
  51. {
  52. public static void main (String[] args) throws java.lang.Exception
  53. {
  54. Student s1 = new Student(173,80);
  55. s1.setName("Mary");
  56. s1.calculate();
  57. //s1.show();
  58.  
  59. Student s2 = new Student("Jennifer",167,53);
  60. s2.calculate();
  61. //s2.show();
  62.  
  63. Student s3 = new Student();
  64. s3.calculate();
  65. //s3.show();
  66.  
  67. s1.toCompare(s2);
  68. s2.toCompare(s1);
  69. s3.toCompare(s1);
  70. s2.toCompare(s3);
  71.  
  72. }
  73. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:43: error: ';' expected
		System.out.println(Math.abs)(Name+"?"+s.Name+"??"+(s.H-H)+"???"+(s.W-W)+"??");
		                            ^
Main.java:43: error: not a statement
		System.out.println(Math.abs)(Name+"?"+s.Name+"??"+(s.H-H)+"???"+(s.W-W)+"??");
		                                                                       ^
Main.java:43: error: ';' expected
		System.out.println(Math.abs)(Name+"?"+s.Name+"??"+(s.H-H)+"???"+(s.W-W)+"??");
		                                                                            ^
3 errors
stdout
Standard output is empty