gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 03:16:32 25 4
gpt4 key购买 nike

除了零之外,我无法将小时或天转换为数字。我做错了什么?
我需要把几分钟变成几小时和几天。

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");
}
}

最佳答案

你的计算有误。您需要如下所示的内容(未经测试):

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");
}

关于java - 我需要帮助找出我做错了什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32429583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com