Write program in java

Time Machine Simulator

Objective: To build a time-traveling program that allows users to travel forward or backward in time in fixed intervals.
Problem statement: You are to create a "Time Machine" simulator. Users can select if they want to travel into the future or the past, and then specify the number of years they want to travel.

Requirements:
Use a for loop to count the years as they pass by
Provide an engaging narrative for the time-travel experience(describe what the world looks like in different eras).

import java.util.Scanner;

public class TimeMachineSimulator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("Welcome to the Time Machine Simulator!");

System.out.print("Do you want to travel into the (1) future or the (2) past? Please enter 1 or 2: ");
int choice = scanner.nextInt();

System.out.print("How many years do you want to travel? Please enter a positive integer: ");
int years = scanner.nextInt();

System.out.println();

System.out.println("Hold on tight! Initiating time travel...");

System.out.println();

if (choice == 1) {
System.out.println("Travelling " + years + " years into the future...");

for (int i = 1; i <= years; i++) {
System.out.println("Year: " + (2022 + i));
System.out.println("Welcome to the future!");
System.out.println("The world has advanced in technology and innovation.");
System.out.println("You see flying cars, robots, and advanced AI everywhere.");
System.out.println("People are living on Mars and exploring the outer reaches of the universe.");
System.out.println();
}

System.out.println("Arrived at the future! Hope you enjoyed the time travel experience!");
} else if (choice == 2) {
System.out.println("Travelling " + years + " years into the past...");

for (int i = 1; i <= years; i++) {
System.out.println("Year: " + (2022 - i));
System.out.println("Welcome to the past!");
System.out.println("The world is filled with history and simplicity.");
System.out.println("You see horse carriages, ancient architecture, and people dressed in traditional clothing.");
System.out.println("There is no electricity, no smartphones, and no internet.");
System.out.println();
}

System.out.println("Arrived at the past! Hope you enjoyed the time travel experience!");
} else {
System.out.println("Invalid choice. Please run the program again and enter a valid choice.");
}

scanner.close();
}
}