Feb 12, 2012

[Java] superposed "for", labeled break

// Java
// superposed "for", labeled break


import java.util.*;

class gugudan_labeled_break
{
 public static void main(String[] args)
 {
 
        System.out.println("Gugudan - start number between 1 and 19");
        Scanner scan = new Scanner (System.in);
        int input;
        
        while(!scan.hasNextInt())
        {
            scan.next();  // if input is not integer value, ignore it.
            System.err.println("Input should be integer value");
        }
        
        
    loop1 :   // loop name for labeled break
        for(input=scan.nextInt(); input<=19; input++)
        {
            for(int j=1; j<=19; j++)
            {
                System.out.print(input+" x "+j+" = "+(input*j)+"   ");
                
                if((input*j)>300)
                    break loop1;     // labeled break
            } 
            
            System.out.println();
        }
 }
}

No comments:

Post a Comment