Write Program Reads Person S First Last Names Separated Space Program Outputs Last Name Co Q37051801

Write a program that reads a person’s first and last names,separated by a space. Then the program outputs last name, comma,first name. End with newline.

Example output if the input is: Maya Jones

Jones, Maya

import java.util.Scanner;

public class SpaceReplace {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String firstName;
String lastName;

/* Your solution goes here */

}
}

(JavaScript language)


Solution


import java.util.Scanner;public class SpaceReplace { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String firstName; String lastName; firstName = scnr.next(); lastName = scnr.next();

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.