you could do it like this :
Code
Scanner sc = new Scanner(System.in);
String answer="";
do{
System.out.println("Do you want to run the program ?");
answer = sc.nextLine();
if ( answer.equals("No") ) return;
} while(true);
or you could use a boolean (run), treat answer and if it's yes your boolean will be true, if it's no the boolean will be false and instead of while(true) you will have while(run) for exemple.