[英]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.