Write a program which prompts a user to enter his first name. There it greets th
ID: 3791235 • Letter: W
Question
Write a program which prompts a user to enter his first name. There it greets the user in this format: Hello first_name how are you? For instance, if the user enter his name as John, the greeting would be Hello John how are you? Write a program which asks the user's first and greets as in Q8 but the greeting is boxed with the at @ characters: Hello John how are you? Here John is an example. You program should be able to greet for any entered name. Write a program which asks the user's name and greets the user in this format: @@ Hello @@ John @@ how @@ are @@ you? @@ where each word is separated by 4 characters which are a space, @, @, and a space characters. Your program must Work for any given name.Explanation / Answer
8)
import java.util.Scanner;
public class GreetingDemo {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("enter your first name");
String fname = scanner.next();
System.out.println("hello " + fname + " how r u?");
}
}
output
enter your first name
john
hello john how r u?
9)
import java.util.Scanner;
public class GreetingDemo {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("enter your first name");
String fname = scanner.next();
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@");
System.out.println("@ hello " + fname + " how r u? @");
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@");
10)
import java.util.Scanner;
public class GreetingDemo {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("enter your first name");
String fname = scanner.next();
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
System.out.println("@@ hello "+"@@ " + fname+" @@ " + " how r u? @@");
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
}
}
output
enter your first name
john
@@@@@@@@@@@@@@@@@@
@@ hello @@ john @@ how r u? @@
@@@@@@@@@@@@@@@@@@
}
}
output
enter your first name
john
@@@@@@@@@@@
@ hello john how r u? @
@@@@@@@@@@@
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.