So the theory is, convert a number to the worded value. 1 = ONE 2 = TWO 3 = THREE etc.. If user enters anything over 5 then display the numerical value of its type. The problem is this:
The output seems to differentiate from what I would hope to be the correct one...
Code :
// Class NumberProgram public int getE() { return e; } public void setE(int e) { l = Integer.toString(e); switch(e) { case 1: l = "ONE"; System.out.println(l); break; case 2: l = "TWO"; System.out.println(l); break; case 3: l = "THREE"; System.out.println(l); break; case 4: l = "FOUR"; System.out.println(l); break; } this.e = e; } // Class - NumberTest import java.util.Scanner; public class NumberTest { public static void main(String[] args) { Scanner kbd = new Scanner(System.in); NumberProgram P = newNumberProgram(); System.out.println("Enter your number: "); int number = kbd.nextInt(); P.setE(number); System.out.println(P.getE()); } } OUTPUT : 3 THREE 3
SO... from what I can see, it seems to be also printing out the value that I enter as well as the worded value... Mhmm.. anyone got any advice?
--- Update ---
Ignore the Integer.toString... I've been working on it for a while and I've been trying alsorts of methods to convert these numbers into worded values :(