Hello ,
I am having trouble with my code I am a beginner and I know I probably made a mistake somewhere but can't figure out where .
-I want to only have 7 letters to output but I can't figure out what is wrong , Every time i type less than 7 letters I get an error
- I want to have an hyphen between the 3 and fourth number but don;t know how to make it work .
-How can I replace a space between an input words by nothing every time I have a space between a word It give me a zero
Please I am stuck if someone can help me.
Thank you so much
static String[] Number1 = new String [7]; static String Number; public static void main (String[] args) { Scanner console = new Scanner(System.in); System.out.print ("Enter a word:"); Number = console.nextLine(); for (int i = 0; i < Number1.length; i++) { System.out.print(Letter(Number.toUpperCase().toLowerCase().charAt(i))); } } public static int Letter (char UppercaseLowerCase) { int print=1 ; if (UppercaseLowerCase=='A' || UppercaseLowerCase=='B' || UppercaseLowerCase== 'C' || UppercaseLowerCase=='a' || UppercaseLowerCase=='b' || UppercaseLowerCase== 'c' ) { print= 2; } else if(UppercaseLowerCase=='D' || UppercaseLowerCase=='E' || UppercaseLowerCase== 'F' || UppercaseLowerCase=='d' || UppercaseLowerCase=='e' || UppercaseLowerCase== 'f' ) { print = 3; } else if (UppercaseLowerCase=='G' || UppercaseLowerCase=='H' || UppercaseLowerCase== 'I' || UppercaseLowerCase=='g' || UppercaseLowerCase=='h' || UppercaseLowerCase== 'i' ) { print = 4; } else if (UppercaseLowerCase=='J' || UppercaseLowerCase=='K' || UppercaseLowerCase== 'L' || UppercaseLowerCase=='j' || UppercaseLowerCase=='k' || UppercaseLowerCase== 'l' ) { print = 5; } else if (UppercaseLowerCase=='M' || UppercaseLowerCase=='N' || UppercaseLowerCase== 'O' || UppercaseLowerCase=='m' || UppercaseLowerCase=='n' || UppercaseLowerCase== 'o' ){ print = 6; } else if (UppercaseLowerCase=='Q' || UppercaseLowerCase=='R' || UppercaseLowerCase== 'S' ||UppercaseLowerCase== 'P'|| UppercaseLowerCase=='q' || UppercaseLowerCase=='r' || UppercaseLowerCase== 's' ||UppercaseLowerCase== 'p') { print = 7; } else if (UppercaseLowerCase=='T' || UppercaseLowerCase=='U' || UppercaseLowerCase== 'V' || UppercaseLowerCase=='t' || UppercaseLowerCase=='u' || UppercaseLowerCase== 'v' ){ print = 8; } else if (UppercaseLowerCase=='W' || UppercaseLowerCase=='X' || UppercaseLowerCase== 'Y' ||UppercaseLowerCase== 'Z' || UppercaseLowerCase=='w' || UppercaseLowerCase=='x' || UppercaseLowerCase== 'y' ||UppercaseLowerCase== 'z' ){ print = 9; } return print ; } }