[英]How to store Data from java.util.Scanner ; How to accept input dealing with time
我正在尝试使用扫描仪来获取时间信息。 因此,这是一个个人锻炼追踪器,我可以输入完成某项锻炼所花费的时间。
Scanner
获取的所有信息都需要存储在电子表格中。 我怎样才能做到这一点
import java.util.Scanner;
// How to arrange the answers to the questions … only if answered “yes” if answered //“no” insert a zero
class WorkOutTracker{
public static void main(String[]args){
System.out.print(“Did you swim today? “)
Scanner myScanner = new Scanner (System.in);
DYSwim = myScanner.nextLine();
if(DYSwim = = “yes”){
System.out.println(“How many laps did you swim? “);
LapNum = myScanner.nextInt();
// how to scan for time.
System.out.println(“Did you Time yourself? “);
DYTime = myScanner.nextLine();
if (DYTime = = “yes”){
System.out.println(“How long did you swim for? “);
SwimTime = myScanner.nextInt();
}
}
}
}
似乎您链接的代码也可以很好地解析秒...
对于电子表格,您可以使用以下api与Excel电子表格进行交互: http : //jexcelapi.sourceforge.net/
我以前用过它,虽然它有些陈旧,但对您来说应该没问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.