laklaker's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
12 (0.02 per day)
Joined:
01-October 12
Profile Views:
190
Last Active:
User is offline Sep 05 2013 01:30 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   laklaker has not set their status

Posts I've Made

  1. In Topic: Problem using [repeating it's output]

    Posted 3 Feb 2013

    I updated it into like this.

    
                    for(int c=top;c<anNumber[i];c--){
                        if(find == anNumber[c]){
                            output += anLetters[c] + "|";
                            System.out.print(output);
                        }
                    }       
    
    
    
  2. In Topic: Problem using [repeating it's output]

    Posted 3 Feb 2013

    The problem now is The error is "java.lang.ArrayIndexOutOfBoundsException: 26". oh gosh. x.x
  3. In Topic: Problem using [repeating it's output]

    Posted 3 Feb 2013

    So at first I just copied the code in this program.

    import java.io.BufferedReader;
    
    import java.io.InputStreamReader;
    
    import java.io.IOException;
    
     
    
    public class ArrayStacks
    
    {
    
    public static void main(String[] args)
    
    {
    
    BufferedReader dataln=new BufferedReader (new InputStreamReader(System.in));
    
    String c="", data="";
    
    String[] arrays = new String[5];
    
    int top=-1, b=0;
    
     
    
    do{
    
    System.out.println("Stack Main Menu");
    
    System.out.println("\n1. Push");
    
    System.out.println("2. Pop");
    
    System.out.println("3. Stack Top");
    
    System.out.print("?: ");
    
     
    
    try{
    
    c=dataln.readLine();
    
    }
    
    catch( IOException e ){
    
    System.out.println("WRONG");
    
    }
    
     
    
    b=Integer.parseInt(c);
    
     
    
    if(b==1){ //stack push
    
    if(top==4){//stack full
    
    System.out.println("\n");
    
    System.out.println("Stack Overflow ");
    
    }
    
    else{
    
    System.out.println("\n");
    
    System.out.println("Stack Push ");
    
    System.out.print("?: ");
    
    try{
    
    data=dataln.readLine();
    
    }
    
    catch( IOException e ){
    
    System.out.println("WRONG");
    
    }
    
    top++;
    
    
    arrays[top]=data;
    
    System.out.println("\nStack");
    
    System.out.println("");
    
    for(int i=top; i>=0; i--){
    
    System.out.println("" + arrays[i]);
    
    }
    
    }
    
    }
    
    System.out.println("\n\n");
    
    }while(b!=4);
    
     
    
    }
    
    }
    
    


    My code is

           top = -1;
           anNumber[0]=1;
                for(i=0;i<anNumber.length;i++){
                    anNumber[i]=i+1;
                }
                
            do{
                    System.out.println("\n\nPlease enter your choice from the following menu:");
                    System.out.println("1. Enter number");
                    System.out.println("2. Exit");
                    choice = Integer.parseInt(reader.readLine());
                    top++;
                switch (choice){
                    case 1:
                    System.out.print("Enter number: ");
                    find=Integer.parseInt(reader.readLine());
                    for(i=top;i<anNumber[i];i--){
                        if(find == anNumber[i]){
                            output += anLetters[i] + "|";
                            System.out.print(output);
                        }
                    }       
                    case 2:
                    break;
                }   
            }while (choice > 0 && choice < 2);
    
    


    The error is "java.lang.ArrayIndexOutOfBoundsException: -1".
  4. In Topic: Problem using [repeating it's output]

    Posted 2 Feb 2013

    So I'm still trying on it but I still have an error.

           String a;
           top = -1;
           anNumber[0]=1;
                for(i=0;i<anNumber.length;i++){
                    anNumber[i]=i+1;
                }
                
            do{
                    System.out.println("\n\nPlease enter your choice from the following menu:");
                    System.out.println("1. Enter number");
                    System.out.println("2. Exit");
                    choice = Integer.parseInt(reader.readLine());
                    top++;
                switch (choice){
                    case 1:
                    System.out.print("Enter number: ");
                    find=Integer.parseInt(reader.readLine());
                    
                    for(i=top;i<=anNumber.length;i--){
                        if(find == anNumber[i]){
                            output += anLetters[i] + "|";
                            System.out.print(output);
                        }
                    }       
                    case 2:
                    break;
                }   
            }while (choice > 0 && choice < 2);
    
    


    It says out of bound.
  5. In Topic: Problem using [repeating it's output]

    Posted 2 Feb 2013

    Yeah. Thanks for that anyway. The problem. It's adding the new on on the bottom.

    The output:
    |B|

    Next will be a:
    |B|a|

    It should be like this:
    |a||B|

    Thank you for your big help GregBrannon!

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

laklaker hasn't added any friends yet.

Comments

laklaker has no profile comments yet. Why not say hello?