码迷,mamicode.com
首页 > 编程语言 > 详细

Java_Switch

时间:2018-07-30 20:15:36      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:ase   style   color   new   stat   def   int   core   void   


import
java.util.Scanner; public class Switch_test{ public static void main(String[] agrs){ float score; Scanner input = new Scanner(System.in); while (true) { System.out.print("请输入你的成绩:"); score = input.nextFloat(); if (score<0||score>100){ System.out.println("请输入百分制成绩!!!!"); } else { int a=(int)score/10; switch(a){ case 10 : System.out.println("A"); break; case 9 : System.out.println("A"); break; case 8 : System.out.println("B"); break; case 7 : System.out.println("C"); break; case 6 : System.out.println("D"); break; default : System.out.println("不及格"); break; } } } } }

Java的switch用法基本和C语言一致

Java_Switch

标签:ase   style   color   new   stat   def   int   core   void   

原文地址:https://www.cnblogs.com/wxzbk/p/9392283.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!