'F' → Fullscreen
Scanner
class file. Scanner
object. import java.util.Scanner;
public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in);
}}
import java.util.Scanner;
public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in);
String task1; String task2; String task3;
System.out.println("--- Demo 1 - Simple To-Do List ---"); System.out.println("Let's add a few tasks to your list."); System.out.print("Task 1: "); task1 = input.nextLine(); System.out.print("Task 2: "); task2 = input.nextLine(); System.out.print("Task 3: "); task3 = input.nextLine();
System.out.println("\nYour To-Do List:"); System.out.println("1. " + task1); System.out.println("2. " + task2); System.out.println("3. " + task3); System.out.print("Press enter to continue..."); input.nextLine(); // Pause before the next demo app// }}
import java.util.Scanner;
public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in);
String task1; String task2; String task3;
System.out.println("--- Demo 1 - Simple To-Do List ---"); System.out.println("Let's add a few tasks to your list."); System.out.print("Task 1: "); task1 = input.nextLine(); System.out.print("Task 2: "); task2 = input.nextLine(); System.out.print("Task 3: "); task3 = input.nextLine();
System.out.println("\nYour To-Do List:"); System.out.println("1. " + task1); System.out.println("2. " + task2); System.out.println("3. " + task3); System.out.print("Press enter to continue..."); input.nextLine(); // Pause before the next demo app
// -----------------------------------------------------------------------------
System.out.println("\n--- Demo 2 - User Profile Setup ---"); System.out.println("WELCOME! LET'S SET UP YOUR PROFILE..."); System.out.print("Enter your username: "); String username = input.nextLine(); System.out.print("What's your favorite subject in school? "); String subject = input.nextLine();
// List of options System.out.println("Choose your preferred after-school activity:"); System.out.println("- Sports"); System.out.println("- Music"); System.out.println("- Gaming"); System.out.println("- Volunteering"); System.out.print("-> "); // This is just an arrow prompt. String activity = input.nextLine();
System.out.println("\n- Creating your profile -"); System.out.println("NAME: " + username); System.out.println("FAVORITE SUBJECT: " + subject); System.out.println("AFTER-SCHOOL ACTIVITY: " + activity); System.out.print("Press enter to continue..."); input.nextLine();// }}
import java.util.Scanner;
public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in);
String task1; String task2; String task3;
System.out.println("--- Demo 1 - Simple To-Do List ---"); System.out.println("Let's add a few tasks to your list."); System.out.print("Task 1: "); task1 = input.nextLine(); System.out.print("Task 2: "); task2 = input.nextLine(); System.out.print("Task 3: "); task3 = input.nextLine();
System.out.println("\nYour To-Do List:"); System.out.println("1. " + task1); System.out.println("2. " + task2); System.out.println("3. " + task3); System.out.print("Press enter to continue..."); input.nextLine(); // Pause before the next demo app
// -----------------------------------------------------------------------------
System.out.println("\n--- Demo 2 - User Profile Setup ---"); System.out.println("WELCOME! LET'S SET UP YOUR PROFILE..."); System.out.print("Enter your username: "); String username = input.nextLine(); System.out.print("What's your favorite subject in school? "); String subject = input.nextLine();
// List of options System.out.println("Choose your preferred after-school activity:"); System.out.println("- Sports"); System.out.println("- Music"); System.out.println("- Gaming"); System.out.println("- Volunteering"); System.out.print("-> "); // This is just an arrow prompt. String activity = input.nextLine();
System.out.println("\n- Creating your profile -"); System.out.println("NAME: " + username); System.out.println("FAVORITE SUBJECT: " + subject); System.out.println("AFTER-SCHOOL ACTIVITY: " + activity); System.out.print("Press enter to continue..."); input.nextLine();
// -----------------------------------------------------------------------------
System.out.println("\n--- Demo 3 - Simple Survey ---"); System.out.println("We'd love to get your feedback!"); System.out.print("What is your favorite color? "); String favoriteColor = input.nextLine(); System.out.print("What is your favorite food? "); String favoriteFood = input.nextLine(); System.out.print("Where is a place you would like to travel? "); String travelDestination = input.nextLine();
System.out.println("\n- Survey Results -"); System.out.println("Favorite Color: " + favoriteColor); System.out.println("Favorite Food: " + favoriteFood); System.out.println("Travel Destination: " + travelDestination); System.out.print("Press enter to continue..."); input.nextLine();// }}
import java.util.Scanner;
public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in);
String task1; String task2; String task3;
System.out.println("--- Demo 1 - Simple To-Do List ---"); System.out.println("Let's add a few tasks to your list."); System.out.print("Task 1: "); task1 = input.nextLine(); System.out.print("Task 2: "); task2 = input.nextLine(); System.out.print("Task 3: "); task3 = input.nextLine();
System.out.println("\nYour To-Do List:"); System.out.println("1. " + task1); System.out.println("2. " + task2); System.out.println("3. " + task3); System.out.print("Press enter to continue..."); input.nextLine(); // Pause before the next demo app
// -----------------------------------------------------------------------------
System.out.println("\n--- Demo 2 - User Profile Setup ---"); System.out.println("WELCOME! LET'S SET UP YOUR PROFILE..."); System.out.print("Enter your username: "); String username = input.nextLine(); System.out.print("What's your favorite subject in school? "); String subject = input.nextLine();
// List of options System.out.println("Choose your preferred after-school activity:"); System.out.println("- Sports"); System.out.println("- Music"); System.out.println("- Gaming"); System.out.println("- Volunteering"); System.out.print("-> "); // This is just an arrow prompt. String activity = input.nextLine();
System.out.println("\n- Creating your profile -"); System.out.println("NAME: " + username); System.out.println("FAVORITE SUBJECT: " + subject); System.out.println("AFTER-SCHOOL ACTIVITY: " + activity); System.out.print("Press enter to continue..."); input.nextLine();
// -----------------------------------------------------------------------------
System.out.println("\n--- Demo 3 - Simple Survey ---"); System.out.println("We'd love to get your feedback!"); System.out.print("What is your favorite color? "); String favoriteColor = input.nextLine(); System.out.print("What is your favorite food? "); String favoriteFood = input.nextLine(); System.out.print("Where is a place you would like to travel? "); String travelDestination = input.nextLine();
System.out.println("\n- Survey Results -"); System.out.println("Favorite Color: " + favoriteColor); System.out.println("Favorite Food: " + favoriteFood); System.out.println("Travel Destination: " + travelDestination); System.out.print("Press enter to continue..."); input.nextLine();
// -----------------------------------------------------------------------------
System.out.println("\n--- Demo 4 - Fantasy Story Builder ---"); System.out.println("Let's create a fantasy story!"); System.out.print("Name your main character: "); String mainCharacter = input.nextLine(); System.out.print("Name a magical creature: "); String magicalCreature = input.nextLine(); System.out.print("Name a magical place: "); String magicalPlace = input.nextLine();
System.out.println("\n- Your Story -"); System.out.println("Once upon a time, there was a hero named " + mainCharacter + "."); System.out.println(mainCharacter + " traveled to the " + magicalPlace + " to seek the legendary " + magicalCreature + "."); System.out.println("Their quest was just beginning...");// }}
Your program output should something similar to the sample output below.
--- Demo 1 - Simple To-Do List ---Let's add a few tasks to your list.Task 1: Do HomeworkTask 2: Cook DinnerTask 3: Clean Bedroom
Your To-Do List:1.Do Homework2.Cook Dinner3.Clean BedroomPress enter to continue...
--- Demo 2 - User Profile Setup ---WELCOME! LET'S SET UP YOUR PROFILE...Enter your username: amortimerWhat's your favorite subject in school? Computer ScienceChoose your preferred after-school activity:- Sports- Music- Gaming- Volunteering-> Gaming
- Creating your profile -NAME: amortimerFAVORITE SUBJECT: Computer ScienceAFTER-SCHOOL ACTIVITY: GamingPress enter to continue...
--- Demo 3 - Simple Survey ---We'd love to get your feedback!What is your favorite color? purpleWhat is your favorite food? Pizza Hut Pepperoni PizzaWhere is a place you would like to travel? Great Britain
- Survey Results -Favorite Color: purpleFavorite Food: Pizza Hut Pepperoni PizzaTravel Destination: Great BritainPress enter to continue...
--- Demo 4 - Fantasy Story Builder ---Let's create a fantasy story!Name your main character: Fart KnightName a magical creature: Logan PaulName a magical place: Cleveland, Ohio
- Your Story -Once upon a time, there was a hero named Fart Knight.Fart Knight traveled to the Cleveland, Ohio to seek the legendary Logan Paul.Their quest was just beginning...
You may write your reflection answers as comments at the bottom of your code.
Scanner.nextLine()
method allow you to make your programs interactive?
Submit your activity and reflection answers to the appropriate dropbox.