Question

6. Write a program that inputs the first name, middle initial (wirh period), and last name of a user and displays that persons n first name first, middle initial followed by a period, and last namelt hel will need the following variables: FirstName (a String) MiddleInitial (a String) LastName (a String) name with the

0 0
Add a comment Improve this question Transcribed image text
Answer #1

NamesTest.java

import java.util.Scanner;

public class NamesTest {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter the first name:");

String firstName = scan.next();

System.out.println("Enter the last name:");

String lastName = scan.next();

System.out.println("Enter the middle initial:");

String middleInitial = scan.next();

System.out.println(firstName+" "+middleInitial+". "+lastName);

}

}

Output:

Enter the first name:
Suresh
Enter the last name:
Kumar
Enter the middle initial:
M
Suresh M. Kumar

Add a comment
Know the answer?
Add Answer to:
6. Write a program that inputs the first name, middle initial (wirh period), and last name...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that reads a person's first and last names, separated by a space. Then...

    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; //answer goes here//    } }

  • Write a program that reads a person's first and last names, separated by a space. Then...

    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 Tones, Maya import java . util·Scanner; public class SpaceReplace 4 public static void main (String [1 ares) f( Scanner scnr-new Scanner(System.in); String firstName; String lastName; Your solution goes here */ 10 12

  • Do WITHOUT #include<sstream> C++ You are to write a program that will read in upto 15...

    Do WITHOUT #include<sstream> C++ You are to write a program that will read in upto 15 names, rearrange each person's name. The list has been collected from different places and the names are not in some standard format. A person's last name may appear last or it may appeaer first. A label has been associated with each name to identify where the last name appears. Either "surname" or "lastname" appears just before a person's last name. The other will be...

  • I need help with this program using c++ language! CS 317 Program Assignment Name Arrange You...

    I need help with this program using c++ language! CS 317 Program Assignment Name Arrange You are to write a program that will read in each person’s name and print out the results. The list has been collected form different places and the names are not in some standard format. A person’s last name may appear last or it may appear first. A label has been associated with each name to identify where the last name appears. Either “surname” or...

  • In C Write a function that asks for the user's first, middle, and last names. The...

    In C Write a function that asks for the user's first, middle, and last names. The names will be entered by the user on a single line and will be stored in three different C-strings. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example, if the user entered...

  • Write a program that prompts the user to enter a list of names. Each person's name...

    Write a program that prompts the user to enter a list of names. Each person's name is separated from the next by a semi-colon and a space (: and the names are entered lastName, firstName (i.e. separated by ',). Your program should then print out the names, one per line, with the first names first followed by the last names. A sample run of your program should look like Please enter your list of names: Epstein, Susan; St. John, Katherine;...

  • In JAVA #3 Write a program named nameChanger.java. This program will only have a driver class...

    In JAVA #3 Write a program named nameChanger.java. This program will only have a driver class with a main. This program will have the user enter a series of names(first and last), which will then be stored in a String array. You will then change the values of each of the names in the array, so that they are stored lastname, firstname, and then output the revised array. Sample: Enter a name (first and last): Tonya Pierce Enter a name...

  • Write a program that separately prompts the user for a first name and last name and...

    Write a program that separately prompts the user for a first name and last name and outputs a string containing the following information, in order: a. First letter of the user's name. b. First five letters of the user's last name. c. A random two-digit integer You must construct the desired string ensuring all characters are lowercase; output the identification string accordingly. Assume the last name contains at least 5 characters. You must use the Random (java.util.Random) class to generate...

  • Design a modular program using pseudo-code which prompts a user for their first name, followed by...

    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...

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT