10/08/2013

12372 - Packing for Holiday - Java

 import java.util.Scanner;  
 public class PackingForHoliday {  
      public static void main(String[] args) {  
           Scanner scan = new Scanner(System.in);  
           int noOfCases = scan.nextInt();  
           int x, y, z;  
           for(int currentCase = 1; currentCase<=noOfCases; currentCase++) {  
                x = scan.nextInt();  
                y = scan.nextInt();  
                z = scan.nextInt();  
                if(x > 20) {  
                     System.out.println("Case " + currentCase + ": bad");  
                     continue;  
                }  
                if(y > 20) {  
                     System.out.println("Case " + currentCase + ": bad");  
                     continue;  
                }  
                if(z > 20) {  
                     System.out.println("Case " + currentCase + ": bad");  
                     continue;  
                }  
                System.out.println("Case " + currentCase + ": good");  
           }  
      }  
 }  

1 comment:

  1. what is the problem of my code?why it didn't accepted? Showing presentation error.
    import java.util.Scanner;
    public class Main {
    public static void main(String[] args) {
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int l,w,h;
    for(int i=1;i<=n;i++) {
    l=s.nextInt();
    w=s.nextInt();
    h=s.nextInt();
    if(l<=20 && w<=20 && h<=20) {
    System.out.println("Case "+" "+i+": good");
    }
    else {
    System.out.println("Case "+" "+i+": bad");
    }
    }
    }
    }

    ReplyDelete