通过new Scanner(System.in)创建一个Scanner,命令行输出
2016-07-04 19:52
459 查看
import java.util.Scanner;
public class MyDate{
public static void main(String[] args){
int sum=0;
Scanner mas = new Scanner(System.in);
System.out.print("请输入学生人数:"+"\t");
int students=mas.nextInt();
int[]score=new int[students];
int temp=0;
for(int i=0;i<score.length;i++){
//Scanner in=new Scanner (System.in);
System.out.print("请输入学生成绩的值:"+"\t");
score[i]=mas.nextInt();
sum+=score[i];
if(i==score.length-1){
temp=i+1;
}
}
System.out.println(temp+"个学生的平均成绩为:"+sum/temp);
}
}
public class MyDate{
public static void main(String[] args){
int sum=0;
Scanner mas = new Scanner(System.in);
System.out.print("请输入学生人数:"+"\t");
int students=mas.nextInt();
int[]score=new int[students];
int temp=0;
for(int i=0;i<score.length;i++){
//Scanner in=new Scanner (System.in);
System.out.print("请输入学生成绩的值:"+"\t");
score[i]=mas.nextInt();
sum+=score[i];
if(i==score.length-1){
temp=i+1;
}
}
System.out.println(temp+"个学生的平均成绩为:"+sum/temp);
}
}
相关文章推荐
- 二维数组静态初始化输出99乘法表
- 如何判断三条线段组成什么三角形
- 运用for循环制作一个99乘法表
- 递归写1,2,3,5,8,13......排序
- 封住、继承、多态案例
- 查询数组中的学生信息
- 正方形边长求面积
- 会员卡系统接入微信卡券那些事儿
- 某些磨人的小程序
- 利用servlet 实现JAVAWeb访问微信OAuth2.0认证,获取用户信息的实例
- 【微信开发】上传下载多媒体文件
- 关于微信网页调用js-sdk相关接口注意事项目(一级域名与二级域名互相干扰!!!)
- 实现微信透明弹窗
- 微信JS-SDK坐标位置如何转换为百度地图坐标
- 【腾讯bugly干货分享】微信Android热补丁实践演进之路
- xz记录 -微信部分
- java微信开发之--更换背景图片
- 【腾讯bugly干货分享】微信Android热补丁实践演进之路
- 微信硬件平台设备直连全讲解(6)设备端SDK导入和设备登陆