The answer will be (a modem) to connect to the internet :)
Answer:
Variable block.
Explanation:
In Computer programming, a variable can be defined as a placeholder or container for holding a piece of information that can be modified or edited.
Basically, variable stores information which is passed from the location of the method call directly to the method that is called by the program.
For example, they can serve as a model for a function; when used as an input, such as for passing a value to a function and when used as an output, such as for retrieving a value from the same function. Therefore, when you create variables in a function, you can can set the values for their parameters.
For instance, to pass a class to a family of classes use the code;
\\parameter Name as Type (Keywords) = value;
\\procedure XorSwap (var a,b :integer) = "myvalue";
Hence, variable block is used to hold values. Also, it can be used to hold strings in variables, which may be displayed through the computer monitor.
Answer:
import java.util.Scanner;
public class HelloIDE
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = input.nextLine();
name = name.trim();
if(name.equals(""))
name = "stranger";
System.out.println("Hello, " + name + "!");
}
}
Explanation:
import the Scanner class to be able to get input from the user
Create an object of the Scanner class called input
Ask the user to enter the name and set it to the name
Trim the name using trim() method, removes the whitespaces from the string
Check the name. If name is equal to "", set the name as stranger. This way if the name is empty, or just contains whitespaces or if name is not given, name will be set as stranger.
Print the name in required format