This is a basic version of the current code i have (be warned i'm new so the stupidity you are about to see will make you mad XD).
package prjWebinar2;
import java.util.Scanner;
public class clsPractice {
public static void main(String[] args) {
// TODO Auto-generated method stub
String answer;
String date;
String time;
Scanner option = new Scanner(System.in);
String[] video = {"abc", "bce", "cde"};
System.out.println("Option 1:" + video[0]);
System.out.println("Would you like to use option1?");
answer = option.nextLine();
if(option.equals("yes")) {
if(option.equals("yes")) {
System.out.println("Please enter a date you would like to show the video:");
date = option.nextLine();
System.out.println("Please enter a time you would like to show the video:");
time = option.nextLine();
}
else {
System.out.println("Option 2:" + video[1]);
System.out.println("Would you like to use this video?");
answer = option.nextLine();
if(option.equals("yes")) {
System.out.println("Please enter a date you would like to show the video:");
date = option.nextLine();
System.out.println("Please enter a time you would like to show the video:");
time = option.nextLine();
}
else {
System.out.println("final option, option 3:" + video[2]);
System.out.println("Would you like to use this video?");
answer = option.nextLine();
if(option.equals("yes")) {
System.out.println("Please enter a date you would like to show the video:");
date = option.nextLine();
System.out.println("Please enter a time you would like to show the video:");
time = option.nextLine();
}
else {
System.out.println("We do not have an other options for videos");
}
}
}
}
}
}
Is there a way that I can implement a for loop instead of using if and else. I need a loop that will print the first value of the array and then only print the second and third based on the user input. May sound vague but I basically want the loop to print the first option, if the user then enters no then the second option is printed etc.
Any help is appreciated!
Thanks, Orson.
do-whileloop"Option 1: blabla, \n Would you like to use this video?"and think of the user experience, it's way easier to just type a number rather than to to type multiple "no"