如何存储来自 java.util.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();
}
}
}
}
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. how can I do this
Full code 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();
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您链接的代码也可以很好地解析秒...
至于电子表格,您可以使用此 api 与 Excel 电子表格进行交互: http://jexcelapi.sourceforge.net/
我以前用过它,虽然它有点过时,但应该适合您使用。
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/
I've used it before and although it's a little dated it should be fine for your use.