134k views
0 votes
write a java program that will 1. welcome the user, 2. prompt the user to enter a name, 3. echo the name entered, 4. display the numbers 11 to 13 (inclusive) twice, as shown in the example, 5. thank the user by name for using the software.

User BozoJoe
by
7.0k points

1 Answer

4 votes

Answer:

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.println("Welcome!");

System.out.print("Please enter your name: ");

String name = input.nextLine();

System.out.println("Hello, " + name + ".");

System.out.println("Here are the numbers 11 to 13, displayed twice:");

for (int i = 1; i <= 2; i++) {

for (int j = 11; j <= 13; j++) {

System.out.print(j + " ");

}

System.out.println();

}

System.out.println("Thank you, " + name + ", for using our software.");

}

}

Step-by-step explanation:

This program uses the Scanner class to read user input and the nested for loop to display the numbers 11 to 13 twice. The program welcomes the user, prompts for their name, echoes the name entered, displays the numbers 11 to 13, and thanks the user by name for using the software.