该程序基本上使用文本文件,读取数据和执行功能:
while(s.hasNext()){
name= s.next();
mark= s.nextDouble();
double percent= (mark / tm )*100 ;
System.out.println("Student Name : " +name );
System.out.println("Percentage In Exam: " +percent+"%");
System.out.println(" ");
}
Run Code Online (Sandbox Code Playgroud)
我想将百分比值格式化为2位小数,但因为它在while循环中,所以我不能使用printf.