Write a class named NameWriter. Javadoc your class and methods. In the class, wr
ID: 3644705 • Letter: W
Question
Write a class named NameWriter. Javadoc your class and methods.In the class, write a method called processName that accepts a Scanner for the console
as a parameter and prompts the user to enter a full name, then prints the name in reverse order (i.e. last name, first name).
Here is an example dialogue with the user (Exercise 3-15):
Please enter your full name: Sammy Jankis
Your name is reverse order is Jankis, Sammy
Call the processName method from the main method.
HINT: Use console.next() twice.
Explanation / Answer
import java.util.*; public class ReverseNames { public static void main(String[] args) { int count = 0; int index = 0; Scanner scan = new Scanner (System.in); String prompt = ("Enter next name: "); System.out.print("This program will ask you to enter some names. How many do you" + " have?"); int amount = scan.nextInt(); String[] name = new String[amount]; String[] reverse = new String[amount]; System.out.print("You entered " +amount+ " as the size of your name list."); System.out.println(" "); for (index = 0; index = 0; index--) { } System.out.println(" "); for (String names1 : name) { System.out.println(names1+" "); } } } /** This program will ask you to enter some names. How many do you have? 3 You entered 3 as the size of your name list. Enter next name: Taylor Enter next name: Zack Enter next name: Sally The names in reverse and original order: Sally Zack Taylor Taylor Zack Sally */Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.