如何存储来自 java.util.Scanner 的数据;如何接受处理时间的输入

发布于 2024-12-17 02:07:55 字数 1055 浏览 1 评论 0原文

我正在尝试使用扫描仪来获取时间信息。所以它是一个个人锻炼追踪器,我可以插入我完成某项锻炼所需的时间。

扫描仪拾取的所有信息都需要存储在电子表格上。我该怎么做

完整代码 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();
            }
        }
    }
}

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

捎一片雪花 2024-12-24 02:07:55

看来您链接的代码也可以很好地解析秒...

至于电子表格,您可以使用此 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文