about summary refs log tree commit diff
path: root/usth/ICT2.2/labwork/1/Hellos.java
blob: 206ac58eb9094c714e2387fb67e9a824b5e1d01f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Hellos
{
  private static final String[] TH = {"th", "st", "nd", "rd", "th",
                                      "th", "th", "th", "th", "th"};

  public static void main(String... args)
  {
    int n = Integer.parseInt(args[0]);
    for (int i = 1; i <= n; ++i)
      // Before one says this defeat the purpose of the section,
      // the tertiary operator IS conditional.
      System.out.println(i + TH[i % 100 / 10 == 1 ? 7 : i % 10] + " Hello");
  }
}