hey guys.
i'm having trouble with looping a program.
my assignment is to get the user to input a string and then display it backwards.
i've successfully done this, but it's supposed to ask if you want to run the program again, and that's where my program fails.

public class backwardstring
    public static void main (String[]args) 
        int choice1 = 1;
        String string;
        final int arraylimit = 30;
        Scanner keyboard = new Scanner (System.in);
        char[] character = new char[arraylimit];
        int i = 0;
            System.out.println("Enter a word or sentence:");
            string = keyboard.nextLine();
            character = string.toCharArray();
            for (i = character.length - 1; i >= 0; i--)
            System.out.println("Would you like to enter another word or sentence?(Y(0)/N(1)");
            choice1 = keyboard.nextInt();
            i = 0;
        while(choice1 == 0);

it completely skips over the for loop after the first time it's run.

help, anyone?


I suppose the problem is solved though you can make it a bit more user friendly by using a char insted of an int like,

char choice;
and then in your while condition use

oh yeah, that's true.
lol plus my teacher is all about making it user friendly all the time.



This question has already been answered. Start a new discussion instead.