Write java code that prompts the user to enter his or her full name, then print the name in reverse order
Answers:
Raw java code:
//Importing the Scanner to get input
import java.util.Scanner;
//creating a class called Name_Reverse
public class Name_Reverse {
//main method
public static void main(String[] args) {
//dialogue to the user
System.out.print("Please enter your
full name: ");
//Creating an object using Scanner
class
Scanner inp=new
Scanner(System.in);
//taking the String using .nextline
method from the object created previously
String name= inp.nextLine();
//splitting the string based on
spaces entered in between the name, and creating the array
String[] rev=name.split(" ");
//output dialogue to the user
System.out.print("Your name in
reverse order is ");
//looping through the array to
print the reverse order of names
for(int i=rev.length-1;i>=0;i--)
{
// condition to
not to print the , at the end as per your requirement show in your
output
if(i==0) {
System.out.print(rev[i]);
}
//condition to
print the reverse of the name by inserting , after every
string
else {
System.out.print(rev[i]+",");
}
}
}
}
Code in Editor:

output:

Please feel free to comment in the comment section if you have any doubts or queris
Thank you :)
Write Java code that prompts the user to enter his or her full name, then prints...
(Obtaining Substrings) Write a program that prompts the user to enter full name contains the first name, middle name and last name separated by a space and extract the first name, middle name and last name from the input string. Here is a sample run: Enter the name: Dennis MacAlistair Ritchie First Name: Dennis Middle Name: MacAlistair Last Name: Ritchie JAVA
1. Write a function that prompts the user to enter his or her first name and last name, as two separate values. This function should return both values to the caller via additional pointer (or reference) parameters that are passed to the function. Try doing this first with pointers and then with references. (Hint: the function signature will look be similar to the swap function from earlier!)
FIRST: Write code that prompts the user for the name of a text file, opens that file if it exists and reads the file one line at a time printing each line to the screen. You must implement the file read in a try/catch block rather than throwing the exception on the main method. NEXT: Modify your code so that the program takes the name of two files from the command line, opens the first file if it exists for...
Problem 1: Dynamic Grocery Array Using Java to write a program that prompts the user to enter an item’s name for each position in the array. The program then prints uses a loop to output the array. Example 1: Banana 2: Orange 3: Milk 4: Carrot 5: Chips Banana, Orange, Milk, Carrot, Chips Problem 2: Print Characters in String Array Declare a string array of size 5. Prompt the user enters five strings that are stored in the array....
java
Write a method named printEntireFile that prompts the user for a file name and points the contents of that file to the console as output. You may assume that the file exists. For example. If the file example. txt contains the following input data: Then the following would be an example dialogue of your method:
Design a modular program using pseudo-code which prompts a user for their first name, followed by their last name; then displays a "Hello" salutation which concatenates their first name with their last name. Sample output (user input shown in red): Please enter your first name: John Please enter your last name: Smith Hello, John Smith! Your program must include a main module and one function; this function prompts the user for either their first name or last name, using a...
Write a Java program called Flying.java that, firstly, prompts (asks) the user to enter an input file name. This is the name of a text file that can contain any number of records. A record in this file is a single line of text in the following format: Num of passengers^range^name^manufacturer^model where: Num of passengers is the total number of people in the plane. This represents an integer number, but remember that it is still part of the String so...
java programe
Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...
Write a program in java that asks a user for a file name and prints the number of characters, words (separated by whitespace), and lines in that file. Then, it replaces each line of the file with its reverse. For example, if the file contains the following lines (Test1.txt): This is a test Hi there Output on the console: Number of characters: 22 Number of words: 6 Number of lines: 2 Data written to the file (Test1.txt): tset a si...
IN JAVA (Maximum consecutive increasingly ordered sub-string) Write a program that prompts the user to enter a string and displays the maximum consecutive increasingly ordered sub-string. Analyze the time complexity of your program and explain. Here is a sample run: Enter a string: abcabcdgabxy output abcdg Time complexity is O( ). -n must be display between the parenthesis.