输入/输出学生信息

package w;
import java.util.Scanner;                          //添加输入库文件包
public class Student {                             //创建类Student

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        String name;
        int age;
        float score;                                   //定义变量
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入学生姓名:");
        name=sc.next();
        System.out.println("请输入学生年龄:");
        age=sc.nextInt();
        System.out.println("请输入一个学生成绩数据:");
        score=sc.nextFloat();                           //从键盘输入学生信息
        System.out.println("你输入的学生姓名为:"+name);
        System.out.println("你输入的学生年龄为:"+age);
        System.out.println("你输入的学生成绩为:"+score);   //输出学生信息
    }

}

输出结果:
输入/输出学生信息_第1张图片

你可能感兴趣的:(输入/输出学生信息)