Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String getOrdinalFor(int value) {
        int tenRemainder = value % 10;
        switch (tenRemainder) {
        case 1:
            return String.valueOf(value) + "st";
        case 2:
            return String.valueOf(value) + "nd";
        case 3:
            return String.valueOf(value) + "rd";
        default:
            return String.valueOf(value) + "th";
        }
    }
}