From 6ab1dab3e860fa7ae8b9d2b68d8c31f3866eedf6 Mon Sep 17 00:00:00 2001 From: mindine <66126505+mindine@users.noreply.github.com> Date: Thu, 3 Sep 2020 04:47:17 +0100 Subject: [PATCH] while loop exercise while loop exercise --- Main.java | 21 +++++++++++++++++++++ src/Main.java | 12 ++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Main.java diff --git a/Main.java b/Main.java new file mode 100644 index 00000000..d6f07013 --- /dev/null +++ b/Main.java @@ -0,0 +1,21 @@ +package src; + +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + boolean isOnRepeat = true; + while (isOnRepeat) { + System.out.println("playing current song"); + System.out.println("would you like to take this song off repeat? If so, answer yes"); + String userInput = input.next(); + + if (userInput.equals("yes")) { + isOnRepeat = false; + } + } + System.out.println("playing next song"); + } +} diff --git a/src/Main.java b/src/Main.java index 30962bf0..d6f07013 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,3 +1,5 @@ +package src; + import java.util.Scanner; public class Main { @@ -5,5 +7,15 @@ public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); boolean isOnRepeat = true; + while (isOnRepeat) { + System.out.println("playing current song"); + System.out.println("would you like to take this song off repeat? If so, answer yes"); + String userInput = input.next(); + + if (userInput.equals("yes")) { + isOnRepeat = false; + } + } + System.out.println("playing next song"); } }