import java.util.*; // abstract checker public class JohnChecker { public static final int MINR = 1; public static final int MAXR = 1000; public static final int MINDXY = 1; public static final int MAXDXY = 3000; public static final int MINXY = -10000; public static final int MAXXY = 10000; public static final double MINP = 0.0; public static final double MAXP = 1.0; public static void printError(int line, String msg) { System.out.println("ERROR Line " + line + ": " + msg); System.exit(-1); } public static void checkIntBounds(int x, int min, int max, String name, int nLines) { if (x < min || x > max) printError(nLines, "invalid " + name + " value: " + x); } public static void checkDoubleBounds(double x, double min, double max, String name, int nLines) { if (x < min || x > max) printError(nLines, "invalid " + name + " value: " + x); } public static void main(String [] args) { Scanner in = new Scanner(System.in); int r, dx, dy, x, y; double p; String line; int nLines=0; line = in.nextLine(); nLines++; StringTokenizer st = new StringTokenizer(line); if (st.countTokens() != 6) printError(nLines, "number of values on line incorrect"); r = Integer.parseInt(st.nextToken()); checkIntBounds(r, MINR, MAXR, "r", nLines); dx = Integer.parseInt(st.nextToken()); checkIntBounds(dx, MINDXY, MAXDXY, "dx", nLines); dy = Integer.parseInt(st.nextToken()); checkIntBounds(dy, MINDXY, MAXDXY, "dy", nLines); x = Integer.parseInt(st.nextToken()); checkIntBounds(x, MINXY, MAXXY, "x", nLines); y = Integer.parseInt(st.nextToken()); checkIntBounds(y, MINXY, MAXXY, "y", nLines); p = Double.parseDouble(st.nextToken()); checkDoubleBounds(p, MINP, MAXP, "p", nLines); if (p == 1.0) printError(nLines, "invalid p value: " + p); if (in.hasNextLine()) printError(nLines, "incorrect number of lines"); System.exit(42); } }