// sampleJJ program
// DK, p&cs
// This program repeatedly reads in a positive integer n,
// stopping when n is less than 0, and prints out the
// sum of the integers from 0 to n.
class SampleJJ
{
  public static void main(String[] args)
  {
    int n, counter, sum;
    println("This is a sample JJ program.");
    println("It uses println, not System.out.println");
    println("It also uses the pacs-jj code for readInt");
    while (true)
    {
      println();
      print("Enter a positive integer [<0 to exit]: ");
      n = readInt();
      if (n < 0)
      {
        break;
      }
      sum = 0;
      counter = 0;
      while (counter <= n)
      {
        sum = sum + counter;
        counter = counter + 1;
      }
      println("0 + 1 + ... + " + n + " = " + sum);
    }
    println("Goodbye!");
  }
  // include pacs-jj code below
  public static void print(Object x) { JJS.outputString(x.toString()); }
  public static void println(Object x) { print(x); JJS.outputlnString(""); }
  public static void println() { println(""); }
  public static void print(int i) { print(new Integer(i)); }
  public static void println(int i) { println(new Integer(i)); }
  public static void print(double d) { print(new Double(d)); }
  public static void println(double d) { println(new Double(d)); }
  public static int readInt() { int x = JJS.inputInt(); println(x); return x; }
  public static int readDouble() { double x = JJS.inputDouble(); println(x); return x; }
}