[英]How to store Data from java.util.Scanner ; How to accept input dealing with time
I am trying to use the Scanner to grab time information. 我正在尝试使用扫描仪来获取时间信息。 So it is a personal workout tracker that I can insert the time it took for me to complete a certain workout.
因此,这是一个个人锻炼追踪器,我可以输入完成某项锻炼所花费的时间。
All the information that the Scanner
picks up will need to be stored on a spread sheet. Scanner
获取的所有信息都需要存储在电子表格中。 how can I do this 我怎样才能做到这一点
Full code http://ideone.com/wYgTc 完整代码http://ideone.com/wYgTc
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();
}
}
}
}
It seems like the code you linked too will work fine for parsing seconds... 似乎您链接的代码也可以很好地解析秒...
As for spreadsheets you can interact with Excel spreadsheets using this api: http://jexcelapi.sourceforge.net/ 对于电子表格,您可以使用以下api与Excel电子表格进行交互: http : //jexcelapi.sourceforge.net/
I've used it before and although it's a little dated it should be fine for your use. 我以前用过它,虽然它有些陈旧,但对您来说应该没问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.