精易论坛

标题: 运用调用方法来判断输入的整数属于什么类型的值 [打印本页]

作者: 4378430    时间: 2017-10-23 01:48
标题: 运用调用方法来判断输入的整数属于什么类型的值
  1. package aiyu.day05;

  2. import java.util.Scanner;

  3. public class Dome_4 {
  4.         public static void main(String[] args) {
  5.                 Scanner sc = new Scanner(System.in);
  6.                 System.out.println("请输入一个整数数值:");
  7.                 int a = sc.nextInt();
  8.                 int c = js(a);
  9.         }

  10.         public static int js(int a) {
  11.                 if (a >= 90 && a <= 100) {
  12.                         System.out.println('A');
  13.                 } else if (a >= 80 && a < 90) {
  14.                         System.out.println('B');
  15.                 } else if (a >= 70 && a < 80) {
  16.                         System.out.println('C');
  17.                 } else if (a >= 60 && a < 70) {
  18.                         System.out.println('D');
  19.                 } else if (a >= 0 && a < 60) {
  20.                         System.out.println('E');
  21.                 } else {
  22.                         System.out.println('F');
  23.                 }
  24.                 return a;

  25.         }
  26. }
复制代码
[attach]695191[/attach][attach]695191[/attach][attach]695191[/attach][attach]695191[/attach]
作者: Sir雨轩    时间: 2017-10-23 07:59
老铁加油
作者: 4378430    时间: 2017-10-24 09:47
Sir雨轩 发表于 2017-10-23 07:59
老铁加油

谢谢大牛的鼓励
作者: wsmwzd    时间: 2018-2-19 07:32
看不懂表了啊,
作者: 青蓝梦    时间: 2018-2-21 10:18
(char)(值)应该就可以实现   
作者: 179    时间: 2018-3-25 13:12
chat()引用应该可以




欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4