java - How can I pause a loop until I get a users input? -
I am starting in Java and I am making a fun project for myself to learn more about Java, I I am planning to randomize the video from a predetermined list and display it to the user.
I am having trouble stopping the loop once you write in the type of video that you want to see to hide the program automatically, but I want you to ask You want to see a second video before it starts again. Even I have so far:
import java.util.Scanner; Import java.util.Random; Public class youtube generator {public static zero main (string [] args) {int randomstring = 0; For (;;) {System.out.println ("\ n --------- Youtube Video Generator 0.001 Beta ------------------ \ n "); System.out.println ("\ n ********* Disclaimer: Warning - This program can direct you to violent, harassing content, and / or obscene language, and only for a mature person It is. *** ****** \ n \ n "); Scanner scan = new scanner (System.in); System.out.println ("What kind of video do you want to see from the list? \"); System.out.println ("Cute \ n" + "Funny \ n" + "WTF \ n" + "Interesting \ n" + "Documentary \ n"); System.out.print ("I want to see:"); String userString = scan.next (); Random rand = new random (); If (userString.equalsIgnoreCase ("cute")) {string cute 1 = "https://www.youtube.com/watch?v=EdCVijVT7Wk"; String cute 2 = "http://youtu.be/-XCvPptsfhI?t=7s"; String cute 3 = "https://www.youtube.com/watch?v=-nkEPsSsH68"; String cute 4 = "https://www.youtube.com/watch?v=FZ-bJFVJ2P0"; String cute 5 = "https://www.youtube.com/watch?v=argCvDpk_KQ"; System.out.println ("Here's a lovely video that you can see:" + lovely 5); } If (userString.equalsIgnoreCase ("weird")) {System.out.println ("Here is a strange thing you can see:"); String funny1 = "https://www.youtube.com/watch?v=I59MgGlh2Mg"; String funny 2 = "http://www.youtube.com/watch?v=HKMNKS-9ugY"; String funny 3 = "https://www.youtube.com/watch?v=_qKmWfED8mA"; String funny 4 = "https://www.youtube.com/watch?v=QDFQYKPsVOQ"; Strings Funny 5 = "https://www.youtube.com/watch?v=ebv51QNm2Bk"; } If (userString.equalsIgnoreCase ("wtf")) {System.out.println ("Here is a WTF video that you can see:"); String wtf1 = "https://www.youtube.com/watch?v=UfKIoSv2YEg"; String wtf2 = "https://www.youtube.com/watch?v=hcGvN0iBA5s"; String wtf3 = "http://www.youtube.com/watch?v=vxnyqvejPjI&feature=youtu.be&t=1m37s"; String wtf4 = "https://www.youtube.com/watch?v=10NJnT6-sSE"; String wtf5 = "https://www.youtube.com/watch?v=DQeyjgSUlrk"; } If (userString.equalsIgnoreCase ("Interesting")) {System.out.println ("Here is an interesting video that you can see:"); String int1 = "https://www.youtube.com/watch?v=fYwRMEomJMM"; String int 2 = "https://www.youtube.com/watch?v=1PmYItnlY5M&feature=youtu.be&t=32s"; String int3 = "https://www.youtube.com/watch?v=HgmnIJF07kg"; String int4 = "https://www.youtube.com/watch?v=cUcoiJgEyag"; String int 5 = "https://www.youtube.com/watch?v=BEPoF4PrwHs"; } If (userString.equalsIgnoreCase ("documentary")) {System.out.println ("Here is a space video that you can see:"); String doc1 = "https://www.youtube.com/watch?v=wS_WlzdOc_A"; String Dock 22 = "https://www.youtube.com/watch?v=8n0SkIGARuo"; String doc33 = "https://www.youtube.com/watch?v=6LaSD8oFBZE"; String doc4 = "https://www.youtube.com/watch?v=zvfLdg2DN18"; String doc5 = "https://www.youtube.com/watch?v=8af0QPhJ22s&hd=1"; }}}}}
Before the closing brace of your loop, insert the following code:
System.out.println ("Do you want to watch another video? Yes or do not enter"); String decision = scan.next (); If (decision.equalsIgnoreCase ("no") break);
Comments
Post a Comment