public static void main(String[] args){
int chinese,manth,english,science,history,number;
Scanner sc = new Scanner(System.in);
System.out.println("请输入您的语文成绩:");
chinese = sc.nextInt();
System.out.println("请输入您的数学成绩:");
manth = sc.nextInt();
System.out.println("请输入您的英语成绩:");
english = sc.nextInt();
System.out.println("请输入您的科学成绩:");
science = sc.nextInt();
System.out.println("请输入您的历史成绩:");
history = sc.nextInt();
if(chinese<=101&&chinese>=-1){
System.out.println("您的语文成绩:"+chinese);}
if(manth<=101&&manth>=-1){
System.out.println("您的数学成绩为:"+manth);}
if(english<=101&&english<=-1){
System.out.println("您的英语成绩为:"+english);}
if(science<=101&&science>=-1){
System.out.println("您的科学成绩为:"+science);}
if(history<=101&&history>=-1){
System.out.println("您的历史成绩为:"+history);}
if(chinese+manth+english+science+history==500);
System.out.println("您的综合成绩为:"+(chinese+manth+english+science+history));
System.out.println("您的成绩表:"+"语文:"+chinese+"数学:"+manth+"英语:"+english+"科学:"+science+"历史:"+history);
}
}
计算出平均成绩,况原有的数据和计算出的平均分数存放在磁盘文件 "stud " 中
这个怎么搞?
能给张截图吗?
追答int chinese;
StringBuffer sb = new StringBuffer();
Scanner sc = new Scanner(System.in);
System.out.println("请输入您的语文成绩:");
chinese = sc.nextInt();
System.out.println("您的语文成绩:"+chinese);
sb.append("Chinese:"+chinese);
File file = new File("d:\\stu.txt");
if(!file.exists()){
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(file);
fos.write(sb.toString().getBytes());
fos.close();