i'm stuck on writing java program on repl.it, ask user enter number between 1 , 10, , result should ordinal number suffix st nd rd , on.
so far have this, displays error of "illegal start of expression" at
public static void main(string[]args) {
what have far
public class ordinals { public static string ordinals(int i) { system.out.println("enter integer between 0 10: "); scanner input = new scanner(system.in); int hundred = value % 100; int tens = value % 10; if (hundred - tens == 10) { return "th"; } switch (tens) { case 1: return "st"; case 2: return "nd"; case 3: return "rd"; default: return "th"; } public static void main(string[] args) { ordinals number = new ordinals(); (int = 1; <= 10; i++) { string st = number.ordinals(i); system.out.println(i + " = " + + st); } } }
Comments
Post a Comment