Hi I am trying to write a program that asks the user for a 2 digit number and then takes that number and prints out its english name.
ex: 45
Forty - Five
The problem I am having at the moment is that I cant figure out how to seperate the 2 numbers so I can work with them seperatly.
this is what I have tried so far:
import jpb.*;
public class NumberName {
public static void main (String[]args){
String Number;
int First,Second;
SimpleIO.prompt("Please enter a 2 digit Number:");
Number = SimpleIO.readLine();
//if (Number.length() > 2 || Number.length() < 1){
// System.out.println("Please only use 2 digit numbers");
//}
First = Integer.parseInt (Number.substring(0));
Second = Integer.parseInt (Number.substring(1));
System.out.println(First);
System.out.println(Second);
}
}
Unfortunately it prints out like this:
Please enter a 2 digit Number:25
25
5
How can I only get the first number?