In: Electrical Engineering
class time{ public static void main (String args[]){ int duration=1500; String testDuration = ""; if(duration < 60){ testDuration = duration + " minutes"; } else{ if((duration / 60)<24) { if((duration%60)==0){ testDuration = (duration / 60) + " hours"; } else{ testDuration = (duration / 60) + " hours," + (duration%60) + " minutes"; } } else{ if((duration%60)==0){ if(((duration/60)%24)==0){ testDuration = ((duration / 24)/60) + " days,"; } else{ testDuration = ((duration / 24)/60) + " days," + (duration/60)%24 +"hours"; } } else{ testDuration = ((duration / 24)/60) + " days," + (duration/60)%24 +"hours"+ (duration%60) + " minutes"; } } } System.out.println(testDuration); } }