Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Tell the user the riddle/joke "Pete and Repeat were fishing and Pete fell off the boat. Who was left?" and ask for the answer. Tell the riddle/joke repeatedly while they input Repeat until they enter Stop.
- Example: Pete and Repeat were fishing and Pete fell off the boat. Who was left?
- Repeat
- Pete and Repeat were fishing and Pete fell off the boat. Who was left?
- Stop
- */
- import java.util.Scanner;
- public class WhileLoop3{
- public static void main(String[] args){
- Scanner kb = new Scanner(System.in);
- System.out.print("Pete and Repeat were fishing and Pete fell off the boat. Who was left?");
- String answer = kb.next();
- while( !answer.equals("stop") && !answer.equals("Stop") ){
- System.out.print("Pete and Repeat were fishing and Pete fell off the boat. Who was left?");
- answer = kb.next();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement