public void exec() throws Exception { IntObj value = new IntObj(), digit = new IntObj(); output += (String.format("\nEnter an integer > ")); value.value = scanner.nextInt(); output += (String.format("\n")); if (value.value > 0) { while (value.value != 0) { digit.value = value.value % 10; value.value = value.value / 10; output += (String.format("%d\n", digit.value)); } } if (value.value < 0) { value.value = Math.abs(value.value); while (value.value > 10) { digit.value = value.value % 10; value.value = value.value / 10; output += (String.format("%d\n", digit.value)); } digit.value = value.value % 10; output += (String.format("-%d\n", digit.value)); } if (value.value == 0) { digit.value = value.value; output += (String.format("%d\n", digit.value)); } output += (String.format("That's all, have a nice day!\n")); if (true) return; ; }
public void exec() throws Exception { IntObj first = new IntObj(), second = new IntObj(), third = new IntObj(), fourth = new IntObj(); output += (String.format("Please enter 4 numbers separated by spaces > ")); first.value = scanner.nextInt(); second.value = scanner.nextInt(); third.value = scanner.nextInt(); fourth.value = scanner.nextInt(); if ((first.value < second.value) && (first.value < third.value) && (first.value < fourth.value)) { output += (String.format("%d is the smallest\n", first.value)); } if ((second.value < first.value) && (second.value < third.value) && (second.value < fourth.value)) { output += (String.format("%d is the smallest\n", second.value)); } if ((third.value < first.value) && (third.value < second.value) && (third.value < fourth.value)) { output += (String.format("%d is the smallest\n", third.value)); } if ((fourth.value < third.value) && (fourth.value < second.value) && (fourth.value < first.value)) { output += (String.format("%d is the smallest\n", fourth.value)); } if (true) return; ; }
public void exec() throws Exception { IntObj digit = new IntObj(), input = new IntObj(); output += (String.format("\nEnter an integer > ")); input.value = scanner.nextInt(); output += (String.format("\n")); while (true) { digit.value = input.value % 10; if (input.value == 0) { output += (String.format("0\n")); break; } else if (Math.abs(digit.value) < 10) { output += (String.format("%d\n", digit.value)); } input.value = input.value / 10; if (Math.abs(input.value) < 10 && input.value != 0) { output += (String.format("%d\n", input.value)); break; } } output += (String.format("That's all, have a nice day!\n")); if (true) return; ; }
public void exec() throws Exception { IntObj x = new IntObj(), y = new IntObj(), z = new IntObj(); output += (String.format("Please enter 3 numbers separated by spaces > ")); x.value = scanner.nextInt(); y.value = scanner.nextInt(); z.value = scanner.nextInt(); if (x.value == y.value) { output += (String.format("%d is the median\n", x.value)); } if (x.value == z.value) { output += (String.format("%d is the median\n", x.value)); } if (y.value == z.value) { output += (String.format("%d is the median\n", y.value)); } if (true) return; ; }
public void exec() throws Exception { IntObj a = new IntObj(); IntObj b = new IntObj(); IntObj c = new IntObj(); output += (String.format("Please enter 3 numbers separated by spaces > ")); a.value = scanner.nextInt(); b.value = scanner.nextInt(); c.value = scanner.nextInt(); if ((a.value >= b.value && a.value <= c.value) || (a.value <= b.value && a.value >= c.value)) { output += (String.format("%d is the median\n", a.value)); } else if ((b.value >= a.value && b.value <= c.value) || (b.value <= a.value && b.value >= c.value)) { output += (String.format("%d is the median\n", b.value)); } else { output += (String.format("%d is the median\n", c.value)); } if (true) return; ; }
public void exec() throws Exception { IntObj a = new IntObj(), b = new IntObj(), c = new IntObj(), median = new IntObj(), temp = new IntObj(); median.value = 0; temp.value = 0; output += (String.format("Please enter 3 numbers separated by spaces > ")); a.value = scanner.nextInt(); b.value = scanner.nextInt(); c.value = scanner.nextInt(); if (a.value >= b.value) { temp.value = b.value; b.value = a.value; a.value = temp.value; } if (a.value < c.value) { median.value = b.value; } else if (b.value > c.value) { median.value = a.value; } else { median.value = c.value; } output += (String.format("%d is the median\n", median.value)); if (true) return; ; }
public void exec() throws Exception { IntObj one = new IntObj(); IntObj two = new IntObj(); IntObj three = new IntObj(); IntObj four = new IntObj(); IntObj small = new IntObj(); IntObj smaller = new IntObj(); IntObj smallest = new IntObj(); output += (String.format("Please enter 4 numbers separated by spaces > ")); one.value = scanner.nextInt(); two.value = scanner.nextInt(); three.value = scanner.nextInt(); four.value = scanner.nextInt(); if (one.value <= two.value) { small.value = one.value; } else { small.value = two.value; } if (small.value <= three.value) { smaller.value = small.value; } else { smaller.value = three.value; } if (smaller.value <= four.value) { smallest.value = smaller.value; } else { smallest.value = four.value; } output += (String.format("%d is the smallest", smallest.value)); if (true) return; ; }
public void exec() throws Exception { IntObj x = new IntObj(), a = new IntObj(), b = new IntObj(), c = new IntObj(), y = new IntObj(); output += (String.format("Enter an integer > ")); b.value = scanner.nextInt(); a.value = b.value / 10; c.value = b.value % 10; if (c.value > 0) { output += (String.format("\n%d\n", c.value)); } else if (c.value < 0) { y.value = c.value * (-1); output += (String.format("%d\n", y.value)); } if (a.value > 0) { while (a.value > 0) { x.value = a.value % 10; a.value = a.value / 10; output += (String.format("%d\n", x.value)); if (a.value < 10) { output += (String.format("%d\nThat's all, have a nice day!\n", a.value)); if (true) return; ; } } } else if (a.value < 0) { a.value = a.value * (-1); while (a.value > 0) { x.value = a.value % 10; a.value = a.value / 10; output += (String.format("%d\n", x.value)); if (a.value < 10) { a.value = a.value * (-1); output += (String.format("%d\nThat's all, have a nice day~\n", a.value)); } } } if (true) return; ; }
public void exec() throws Exception { IntObj n = new IntObj(); IntObj x = new IntObj(), y = new IntObj(); IntObj temp = new IntObj(); output += (String.format("\nEnter an integer > ")); y.value = scanner.nextInt(); n.value = 0; while (n.value <= 10) { x.value = y.value % 10; output += (String.format("\n%d", Math.abs(x.value))); x.value = y.value / 10; if (x.value > -10 && x.value < 0) { output += (String.format("\n%d", x.value)); output += (String.format("\nThat's all, have a nice day!\n")); if (true) return; ; } temp.value = x.value; x.value = y.value; y.value = temp.value; n.value = n.value + 1; } if (true) return; ; }