Exemplo n.º 1
0
  public static void main(String[] args) {
    Console c = new Console();
    int numb[];
    int answer = 0;
    int remain = 0;
    numb = new int[2];

    for (int x = 0; x <= 1; x++) {
      c.print("Enter number " + (x + 1) + ": ");
      numb[x] = c.readInt();
    }
    if (numb[0] <= numb[1]) {
      answer = numb[1] / numb[0];
      remain = numb[1] % numb[0];
      c.print(
          ""
              + numb[1]
              + " divided by "
              + numb[0]
              + " equals "
              + answer
              + " with a remainder of "
              + remain);
    } else if (numb[1] < numb[0]) {
      answer = numb[0] / numb[1];
      remain = numb[0] % numb[1];
      c.print(
          ""
              + numb[0]
              + " divided by "
              + numb[1]
              + " equals "
              + answer
              + " with a remainder of "
              + remain);
    }
  }
Exemplo n.º 2
0
 public static void main(String[] args) {
   Console c = new Console();
   Format f = new Format();
   double salaryold = 0, salarynew = 40000, raise = 40000;
   c.print(Format.justify('r', "Year", 6));
   c.print(Format.justify('r', "Old Salary", 15));
   c.print(Format.justify('r', "Raise", 11));
   c.print(Format.justify('r', "New Salary\n", 17));
   c.print(Format.justify('r', "----", 6));
   c.print(Format.justify('r', "--- ------", 15));
   c.print(Format.justify('r', "-----", 11));
   c.print(Format.justify('r', "--- ------\n", 17));
   for (int x = 0; x <= 9; x++) {
     c.print(Format.justify('r', x + 1, 6));
     c.print(Format.justify('r', salaryold, 15, 2));
     c.print(Format.justify('r', raise, 12, 2));
     c.println(Format.justify('r', salarynew, 14, 2));
     raise = (salarynew * .03);
     salaryold = salarynew;
     salarynew = raise + salaryold;
   }
 }