import java.io.*; class Itoa { /* --- myToString(): Integer to Ascii conversion function --- */ public static String myToString(int value) { int sign, i, j; String result; char next_char; int next_digit; /* ----------------------------------------- Handel 0 ----------------------------------------- */ if (value == 0) return("0"); /* --------------------------------------- Check sign --------------------------------------- */ if (value < 0) { sign = -1; value = -value; } else { sign = 1; } /* --------------------------------------- Handel > 0 --------------------------------------- */ result = ""; while (value > 0) { next_digit = value % 10; next_char = (char) (next_digit + '0') ; result = next_char + result; // Append at front !! value = value / 10; } // Put in the negative sign.... if (sign == -1) { result = "(" + result + ")"; // Try: "******" + result for banks } else { result = "+++++++" + result; // Does nothing... } return(result); } public static void main(String[] args) throws IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in)); String s1, s2; int i1, i2; System.out.print("Enter integer i1: "); i1 = Integer.parseInt( stdin.readLine() ); System.out.print("Enter integer i2: "); i2 = Integer.parseInt( stdin.readLine() ); System.out.println("i1 + i2 = " + (i1 + i2) + "\n" ); s1 = myToString(i1); s2 = myToString(i2); System.out.println("String s1 = " + s1 ); System.out.println("String s2 = " + s2 ); System.out.println("s1 + s2 (string concatenation !) = " + (s1 + s2) ); } }