UVA 12372 – Packing for Holiday

I tried to use three sc.nextInt()‘s inside the if statement. That failed terribly :(

Super easy problem otherwise.

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 
 * @author Sanchit M. Bhatnagar
 * @see http://uhunt.felix-halim.net/id/74004
 * 
 */
public class P12372 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int T = sc.nextInt();
    for (int i = 1; i <= T; i++) {
      out.print("Case " + i + ": ");
      int l = sc.nextInt();
      int w = sc.nextInt();
      int h = sc.nextInt();
      if (l <= 20 && w <= 20 && h <= 20) {
        out.println("good");
      } else {
        out.println("bad");
      }
    }

    out.close();
    sc.close();
  }

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.