返回列表 發帖

206-及格成績

import java.util.*;
public class JPA02 {
    static Scanner keyboard = new Scanner(System.in);
    public static void main(String[] args) {
        test();        
        test();
        test();
        test();
    }
   
    static void test() {
        int chi, eng, math, avg;
        System.out.print("Input Chinese score:");
        chi = keyboard.nextInt();
        System.out.print("Input English score:");
        eng = keyboard.nextInt();
        System.out.print("Input Math score:");
        math = keyboard.nextInt();
        
        ...
    }
}
Stay hungry,
Stay foolish.

import java.util.Scanner;


public class JPA01 {
          static Scanner o= new Scanner(System.in);
        public static void main(String[] args) {
                // TODO 自動產生的方法 Stub
               
                test();
                test();
                test();
                test();
               
                       
                }
               
          
        private static void test() {
                // TODO 自動產生的方法 Stub
               
                 
               
                 System.out.print("Input Chinese score:");
                 int c = o.nextInt();
                
                System.out.print("Input English score:");
                int e = o.nextInt();
                System.out.print("Input Math score:");
               int  m = o.nextInt();
               if(c<60)
                          {
                                  System.out.println("Chinese failed");
                          }
                  if(e<60)
                  {
                          System.out.println("English failed");
                  }
                  if(m<60)
                  {
                          System.out.println("Math failed");
                  }
                  else
                  {
                          System.out.println("All past");  
                  }
        }
       

}

TOP

本帖最後由 巫沛庭 於 2018-6-19 20:06 編輯
  1. import java.util.*;
  2. public class JPA02 {
  3.     static Scanner keyboard = new Scanner(System.in);
  4.     public static void main(String[] args) {
  5.         test();        
  6.         test();
  7.         test();
  8.         test();
  9.     }
  10.    
  11.     static void test() {
  12.         int chi, eng, math, avg;
  13.         System.out.print("Input Chinese score:");
  14.         chi = keyboard.nextInt();
  15.         System.out.print("Input English score:");
  16.         eng = keyboard.nextInt();
  17.         System.out.print("Input Math score:");
  18.         math = keyboard.nextInt();
  19.         
  20.        if(chi<60)
  21.        {
  22.               System.out.println("Chinese faild.");
  23.        }
  24.        if(eng<60)
  25.        {
  26.               System.out.println("English faild.");
  27.        }
  28.        if(math<60)
  29.        {
  30.               System.out.println("Math faild.");
  31.        }
  32.        if(chi>=60 && eng>=60 && math>=60)
  33.        {
  34.               System.out.println("All Pass.");
  35.        }
  36.     }
  37. }
複製代碼

TOP

  1. import java.util.Scanner;


  2. public class OP321 {
  3.            static Scanner keyboard = new Scanner(System.in);
  4.             public static void main(String[] args) {
  5.                 test();        
  6.                 test();
  7.                 test();
  8.                 test();
  9.             }
  10.             
  11.             static void test() {
  12.                 int chi, eng, math, avg;
  13.                 System.out.print("Input Chinese score:");
  14.                 chi = keyboard.nextInt();
  15.                 System.out.print("Input English score:");
  16.                 eng = keyboard.nextInt();
  17.                 System.out.print("Input Math score:");
  18.                 math = keyboard.nextInt();
  19.                 
  20.                 if(chi<60)
  21.                 {
  22.                         System.out.println("Chinese failed");       
  23.                 }
  24.                  if(eng<60)
  25.                 {
  26.                         System.out.println("English failed");       
  27.                 }
  28.                 if(math<60)
  29.                 {
  30.                         System.out.println("Math failed");       
  31.                 }
  32.                 if(chi>=60&&eng>=60&&math>=60)
  33.                 {
  34.                         System.out.println("All Pass");       
  35.                 }
  36.                 }
  37.             }
複製代碼

TOP

返回列表