Wrong Answer

2017131541 Reply 5 years 28 weeks ago
Hello Professor, I am constantly getting the wrong answer despite getting the right output. Could you please tell me where I am going wrong? public class Main { public static void main(String[] args) { int a = 2015; int seconds = a % 60; int hours = a / 60; int minutes = hours % 60; hours = hours / 60; System.out.println(hours + " " + minutes + " " + seconds); } } Another method that I used was: public class Main { public static void main(String[] args) { int a = 2015; int b = a / 3600; int c = a / 60; int d = a % 60; System.out.println(b + " " + c + " " + d); } }
muramura12 Reply 5 years 28 weeks ago
uh... i think a = 2015 is wrong. you should input variable(in your code, 'a') through cmd. use Scanner class
onacloud Reply 5 years 27 weeks ago
I think so too