So I am trying to convert an int to string and then charAt(0), charAt(1), and charAt(2). I did that to split the 3 digit int to 3 different integers. I want to then convert those individual integers to Strings.
What I am trying to do is take numbers from 101 and above and print them in words. I have hundreds, tens and ones methods. I am trying to take first integer and apply it to the hundreds method, second integer and apply it to the tens, and third integer to ones method.
this is the method of >= 101
import java.util.Scanner;
public class rough {
public static void main(String args[]) {
int number = 0;
Scanner scanner = new Scanner(System.in);
System.out.print("Please type a number between 0 and 999 OR type -1 to exit: ");
number = scanner.nextInt();
if (number >= 101) {
System.out.println(hundred(first) + " AND" + tens(second) + "" + From1To19(third));
} else {
System.out.println("please input a number from 101: ");
}
//this is what i have so far(might be junk).
public static void From101(int num) {
String SNumber = Integer.toString(num);
char First = SNumber.charAt(0);
char Second = SNumber.charAt(1);
char Third = SNumber.charAt(2);
int num1 = Integer.parseInt(first);
}
}
Now I am trying to print the words and i am getting 3 errors.
System.out.println(hundred(first) + " AND" + tens(second) + "" + From1To19(third));
I add that line in my if/else statement and the errors are:
----jGRASP exec: javac -g rough.java
rough.java:27: error: 'void' type not allowed here
System.out.println(hundred(first) + " AND" + tens(second) + "" + From1To19(third));
^
rough.java:27: error: 'void' type not allowed here
System.out.println(hundred(first) + " AND" + tens(second) + "" + From1To19(third));
^
rough.java:27: error: 'void' type not allowed here
System.out.println(hundred(first) + " AND" + tens(second) + "" + From1To19(third));
^
3 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.