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. 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();


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.

链接地址: http://www.djcxy.com/p/96106.html

上一篇: 现在我在使用if else语句时出现不兼容的错误

下一篇: 如何存储来自java.util.Scanner的数据; 如何接受处理时间的投入