Advertisement
roronoa

siècle, century

Jul 8th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. /**
  2.  * Auto-generated code below aims at helping you parse
  3.  * the standard input according to the problem statement.
  4.  **/
  5.  
  6. const y = parseInt(readline());
  7. r = ""
  8. let neg = false;
  9. if(y == 0)
  10.     console.log("INVALID");
  11. else
  12. {
  13.     if(y > 0)
  14.         x = Math.ceil(y/100)
  15.    
  16.     else
  17.     {
  18.         x = Math.ceil(Math.abs(y/100));
  19.         neg = true;
  20.     }
  21.        
  22.     r += x;
  23.     if(x%10 == 1)
  24.         r+="st";
  25.     else if(x%10 == 2)
  26.         r+="nd";
  27.     else if(x%10 == 3)
  28.         r+="rd";
  29.     else
  30.         r+="th";
  31.     r+=" century ";
  32.     if(neg)
  33.         r+= "B";
  34.     r+="CE";
  35.     console.log(r);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement