日期:2014-05-20 浏览次数:20944 次
import java.io.FileOutputStream;
import java.util.Scanner;
/**
* Stud.java
* 2007-10-7 上午09:48:34
* TODO
*/
/**
* @author ustbsjl
*
*/
public class Stud {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
String name = null;
double firstScore = 0.0;
double secendScore = 0.0;
double thirdScore = 0.0;
double avg = 0.0;
StringBuffer sb = new StringBuffer("[Stu info]\n");
Scanner sc = new Scanner(System.in);
for (int i = 1; i <= 2; i++) {
System.out.println("please enter stu " + i + " info...");
System.out.print("Name: ");
name = sc.next();
System.out.print("FirstScore: ");
firstScore = sc.nextDouble();
System.out.print("SecendScore: ");
secendScore = sc.nextDouble();
System.out.print("ThirdScore: ");
thirdScore = sc.nextDouble();
avg = (firstScore + secendScore + thirdScore) / 3;
System.out.println("This stu's Avg score is " + avg);
sb.append("Name: " + name + ", FirstScore: " + firstScore
+ ", SecendScore: " + secendScore + ", ThirdScore: "
+ thirdScore + ", Avg: " + avg + "\n");
}
FileOutputStream fout = new FileOutputStream("stud.txt");
fout.write(sb.toString().getBytes());
}
}