Skip to content

Instantly share code, notes, and snippets.

@oiojin831
Last active September 17, 2021 06:44
Show Gist options
  • Save oiojin831/9956afb44521ede2f545c04d4fbc6bee to your computer and use it in GitHub Desktop.
Save oiojin831/9956afb44521ede2f545c04d4fbc6bee to your computer and use it in GitHub Desktop.
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
String name = "not specified";
String artist = "not specifie";
String[] movies = new String[5];
int number;
boolean loop = true;
while (loop) {
System.out.println();
System.out.println("******** " + "Movie App" + " ********");
System.out.println("1. Add your name");
System.out.println("2. Add your 5 best movies");
System.out.println("3. Add your favorite artist");
System.out.println("4. Print all information");
System.out.println("5. Exit");
System.out.print("Select number: ");
number = stdIn.nextInt();
stdIn.nextLine();
if (number == 1) {
System.out.print("What is you name?: ");
name = stdIn.nextLine();
} else if (number == 2) {
System.out.print("What is your 5 best movies?: ");
for(int i=0; i<movies.length; i++) {
movies[i] = stdIn.nextLine();
}
} else if (number == 3) {
System.out.print("What is you favorite artist?: ");
artist = stdIn.nextLine();
} else if (number == 4) {
System.out.println("My name is " + name);
for(int i=0; i<movies.length; i++) {
System.out.println(movies[i]);
}
System.out.println("My favorite artist is " + artist);
} else {
System.out.println("EXIT");
loop = false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment