Demo entry 5853896

Test

   

Submitted by anonymous on Jul 20, 2016 at 16:45
Language: Java. Code size: 1.4 kB.

public class NoonSnooze {	
    public static void main(String[] args) {	
        //Establishes argument is an integer//	
        int r = 12;	
        int q = 60;	
        int w = 24;	
        int snooze    = Integer.parseInt(args[0]);	
        int hour      = r + snooze / q;	
        /*/minute after the hour represented by remainder when minutes 		
        divided by 60/*/	
        int minute    = snooze % q;	
        int hrs       = 0;	
        String time   = "";	
        String mins = "";	
        	
        //otherwise remainder is zero and it prints hour is 0//	
        if (hour == w)	
            hrs = r;	
        else	
        {	
            //finds hour on clock by remainder of hour when divided by 12//	
            if (hour > r)		
                hrs = hour % r;		
            else {	
                hrs = r;	
            }	
        }	
        //after noon when remainder of hour is greater than 12	
        if (hour % w >= 12)	
            time = "pm";	
        //before noon when remainder of hour is less than 12	
        else	
        {	
            time = "am";	
        }	
        //prints 0 before single digit minute	
        if (minute < 10)	
            mins = "0" + minute; 	
        else		
        {		
            mins = "" + minute;		
        }		
        //prints time after snooze	
        System.out.println(hrs + ":" + mins + time);	
    }	

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).