1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

java - print numbers as word equivalent but in reverse

Discussion in 'Programming' started by javanewbie, Sep 8, 2011.

  1. javanewbie

    javanewbie New Member

    Sep 8, 2011
    Likes Received:
    Trophy Points:
    I am working on a program in java on notepad++ that opens a file(reverse.in) opens it and extracts the integers to an array. Now I need convert the numbers to words and print them out in reverse. For example 0 1 2 3 would become three two one zero.

    I have the array set but have no idea how to convert the numbers and print in reverse. This is only my 3rd week of java so the more info the better!!!
    import java.util.*;
    import java.io.*;
    public class Reverse1{
    public static void main(String[] args) throws Exception{
    int i =0;
    File file = null;
     file = new File("Reverse.in");
     BufferedReader bufRdr  = new BufferedReader(new FileReader(file));
     String line = "";
     String [] numbers = new String[10];
      while ((line = bufRdr.readLine()) != null){
      StringTokenizer st = new StringTokenizer(line,",");
    while (st.hasMoreTokens()) {
    numbers[i]= st.nextToken();
    for (i = 1; i < numbers.length; i++) {  
    System.out.print("" + numbers[i]); 
    Last edited by a moderator: Sep 9, 2011

Share This Page