简体   繁体   English

我需要帮助找出我做错了什么

[英]I need help figuring out what i did wrong

I can't get the hours or day into a number but Zero. 我无法将小时数或天数归为零。 What I am i doing wrong? 我做错了什么?
I need to get minutes into hours and days. 我需要把时间花在数小时和数天之内。

import java.util.Scanner;

public class NewClass 
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        int minutes=0,hours=0,days=0, years=0;
        System.out.println("Enter the number of mintues");
        minutes= input.nextInt();

        minutes += (hours*60);
        hours += (days*1440);
        days += (years*365);
        System.out.println("The amount of Hours in minute is: "+hours + "hours");
        System.out.println("The amunt of Days is in mintue is: " +days +"days");
    }
}

Your calculation is wrong. 您的计算是错误的。 You need something like below(untested): 您需要以下内容(未经测试):

public static void main(String[] args)
 {
    Scanner input = new Scanner(System.in);
    int minutes=0,hours=0,days=0, years=0;
    System.out.println("Enter the number of mintues");
    minutes= input.nextInt();

    hours = (minutes/60);
    days = (minutes/1440);
    System.out.println("The amount of Hours in minute is: "+hours + "hours");
    System.out.println("The amunt of Days is in mintue is: " +days +"days");
}

I think you used the 0 instead of the value of minute. 我认为您使用的是0而不是分钟的值。 Please refer below: 请参考以下内容:

            Scanner input = new Scanner(System.in);
            int minutes=0,hours=0,days=0, years=0;
            System.out.println("Enter the number of mintues");

            //get minute
            minutes= input.nextInt();
            //calculate hours
            hours = minutes / 60;
            //calculate days
            days = hours/24;
            //calculate year
            years = days/365;
            System.out.println("The amount of Hours in minute is: "+hours + "hours");
            System.out.println("The amunt of Days is in mintue is: " +days +"days");

Hope this help. 希望对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 一些帮助找出我的Eratosthenes筛子出了什么问题 - Some help figuring out what's wrong with my Sieve of Eratosthenes 需要帮助弄清楚为什么我不能使用自定义ArrayAdapter更改TextView文本 - Need help figuring out why I cannot change TextView text using a custom ArrayAdapter 需要帮助弄清楚为什么我单击启动时应用崩溃并停止播放视频的原因吗? - Need help figuring out why app crashes and stop video is called when I click to start it instead? 我需要帮助弄清楚如何阻止我的程序抛出NullPointerException - I need help figuring out how to stop my program from throwing a NullPointerException 需要帮助弄清楚如何大写从文本文件中读取的任何小写“i” - Need help figuring out how to capitalize any lower case "i" read from a text file 我需要帮助弄清楚为什么清除按钮代码不起作用 - I need help figuring out why my clear button code does not work 有谁能在这份准备好的声明中找出我做错了什么? - Could anyone find out what i did wrong in this prepared statement? 我正在我的 java class 中处理数据库,我需要帮助弄清楚如何更新数据库中的特定值/列 - I'm working on databases in my java class, and I need help figuring out how to update a specific value/column in the database 需要帮助找出我的代码中的错误 - Need help figuring it out errors with my code 需要帮助找出正确的正则表达式模式 - Need help in figuring out the right regex pattern
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM