[Java] 118-学生类 →→→→→进入此内容的聊天室

来自 , 2020-06-13, 写在 Java, 查看 116 次.
URL http://www.code666.cn/view/4fa53be9
  1. import java.util.Scanner;
  2. public class Main{
  3.     public static void main(String[] args) {
  4.          Scanner scan = new Scanner(System.in);
  5.          int no = scan.nextInt();
  6.          String name = scan.next();            
  7.          int score = scan.nextInt();
  8.          Student s1 = new Student(no, name, score);
  9.          no = scan.nextInt();
  10.          name = scan.next();            
  11.          score = scan.nextInt();
  12.          Student s2 = new Student(no, name, score);
  13.          no = scan.nextInt();
  14.          name = scan.next();            
  15.          score = scan.nextInt();
  16.          Student s3 = new Student(no, name, score);
  17.          if(s1.getScore() > s2.getScore())
  18.          {
  19.                  if(s1.getScore() > s3.getScore())
  20.                  {
  21.                          s1.print();
  22.                          if(s2.getScore() > s3.getScore())
  23.                          {
  24.                                  s2.print();
  25.                                  s3.print();
  26.                          }
  27.                          else
  28.                          {
  29.                                  s3.print();
  30.                                  s2.print();
  31.                          }
  32.                  }
  33.                  else
  34.                  {
  35.                          s3.print();
  36.                          s1.print();
  37.                          s2.print();
  38.                  }
  39.          }
  40.          else
  41.          {
  42.                  if(s1.getScore() > s3.getScore())
  43.                  {
  44.                          s2.print();
  45.                          s1.print();
  46.                          s3.print();
  47.                  }
  48.                  else
  49.                  {
  50.                          if(s2.getScore() > s3.getScore())
  51.                          {
  52.                                  s2.print();
  53.                                  s3.print();
  54.                          }
  55.                          else
  56.                          {
  57.                                  s3.print();
  58.                                  s2.print();
  59.                          }
  60.                          s1.print();
  61.                  }
  62.          }
  63.          scan.close();
  64.     }
  65. }
  66. class Student
  67. {
  68.         private int no;
  69.         private String name;
  70.     private int score;
  71.         public Student(int _no, String _name, int _score) {
  72.                 no = _no;
  73.                 name = _name;
  74.         score = _score;
  75.         }
  76.     public int getNo() {return no;}
  77.     public String getName() {return name;}
  78.     public int getScore() {return score;}
  79.        
  80.         public void print(){
  81.                 System.out.println(no + " "+name+" "+score);
  82.         }
  83. }

回复 "118-学生类"

这儿你可以回复上面这条便签

captcha