简体   繁体   中英

Why do I get the wrong output message?

I keep getting a wrong output message, even though the program runs and gives me the correct answer.

public class SecondsOfTheYear {

    public static void main(String[] args) {   
        int daysInYear = 365;
        int hoursInDay = 12;
        int minutesInHour = 60;
        int secondsInMinute = 60;

        int secondsInYear = (daysInYear * hoursInDay * minutesInHour * secondsInMinute);

        System.out.println("There are " + secondsInYear + " seconds in a year");
    }    

}

Apart from there being 24 hours in a day, the program seems fine.

Can you be more specific about your problem? "I keep getting a wrong output message, even though the program runs and gives me the correct answer" is not very descriptive :S

一天有24小时,您写的有12小时

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM