Question

In: Computer Science

jgrasp environment, java write a complete program that prompts the user to enter their first name,...

jgrasp environment, java

write a complete program that prompts the user to enter their first name, middle name, and last name (separately). print out thier name and initials, exactly as shown:

your name is: John Paul Chavez

your initials are: J. P. C.

use string method chartAt() to extract the first (zero-th) character from a name(the name is a string type): username.charAt(0).

thank you.

Solutions

Expert Solution

Program :

import java.util.Scanner; // Import the Scanner class
class Myclass
{
   public static void main(String args[])
   {
Scanner obj = new Scanner(System.in); // Create a Scanner object
  
       System.out.println("Enter your first name:");
String FirstName = obj.nextLine();
  
System.out.println("Enter your middle name:");
String MiddleName = obj.nextLine();

System.out.println("Enter your middle name:");
String LastName = obj.nextLine();

System.out.println("your name is:"+FirstName+" "+MiddleName+" "+LastName);
  
System.out.println("your initials are:"+FirstName.charAt(0)+"."+MiddleName.charAt(0)+"."+LastName.charAt(0)+".")
  
   }
}

Screen shot of the program with out put:


Related Solutions

Write a JAVA program that prompts the user to enter a single name. Use a for...
Write a JAVA program that prompts the user to enter a single name. Use a for loop to determine if the name entered by the user contains at least 1 uppercase and 3 lowercase letters. If the name meets this policy, output that the name has been accepted. Otherwise, output that the name is invalid.
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for the check amount, then ask the user what type of tipp they would like to leave: the choices are 1 for good tip (20%), 2 for an average tip (15%), or 3 for poor tip (10%). Use their input and an if-else to calculate the tip amount. Then calculate and output the final bill: check+tip print out the bill, exactly as shown (print the...
USING jgrasp environment, javascript rite a complete program that prompts the user for two integers and...
USING jgrasp environment, javascript rite a complete program that prompts the user for two integers and then prints the following report to the screen, exactly as shown. example, using 23 and 18 as the user input: your numbers are :23 and 18 sum=41 product=414 use the scanner class nextlnt() method to read the user's numbers: scanner keyboard... ...keyboard.nextlnt()
Write a Java program that prompts the user to enter a list of integer values and...
Write a Java program that prompts the user to enter a list of integer values and displays whether the list is sorted in increasing order or not. Here is a sample run. Note that the first number in the input indicates the number of the elements in the list. <Output> Enter list: 8 101516619111 The list is not sorted <End Output <Output> Enter list: 10 11344579 11 21 The list is already sorted <End Output Create a complete class for...
java language NetBeans Write a program that prompts the user to enter the weight of a...
java language NetBeans Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds. Output both the weights rounded to two decimal places. (Note that 1 kilogram = 2.2 pounds.) Format your output with two decimal places.
In Java: Write a program that prompts the user to enter a positive number until the...
In Java: Write a program that prompts the user to enter a positive number until the user input a negative number. In the end, the program outputs the sum of all the positive numbers. You should use do-while loop (not while, not for). You cannot use break or if statement in the lab. Hint: if the program adds the last negative number to your sum, you can subtract the last number from the sum after the loop.
JAVA Write a test program that prompts the user to enter a series of integers and...
JAVA Write a test program that prompts the user to enter a series of integers and displays whether the series contains runLength consecutive same-valued elements. Your program’s main() must prompt the user to enter the input size - i.e., the number of values in the series, the number of consecutive same-valued elements to match, and the sequence of integer values to check. The return value indicates whether at least one run of runLength elements exists in values. Implement the test...
Write a program that prompts the user to enter a file name, then opens the file...
Write a program that prompts the user to enter a file name, then opens the file in text mode and reads names. The file contains one name on each line. The program then compares each name with the name that is at the end of the file in a symmetrical position. For example if the file contains 10 names, the name #1 is compared with name #10, name #2 is compared with name #9, and so on. If you find...
Write a program that prompts the user enter a word, and determines the first half and...
Write a program that prompts the user enter a word, and determines the first half and second half of the word. Print the first and second half of the word on different lines. Sample runs of the program are shown below. Note: If the word is an odd number of letters, the first half should contain fewer letters (as shown in sample run #2) SAMPLE PROGRAM RUN #1                     Enter a word: carrot First half: car Second half: rot SAMPLE PROGRAM...
First, the Python program prompts user to enter user information (name, email, and phone number). Then...
First, the Python program prompts user to enter user information (name, email, and phone number). Then it displays a menu called “Fish Information” that has the following fish type: 1. Cat Fish 2. Red Fish 3. Any other fish Let user choose the fish type that he/she got and input the length of the fish. Then the program will determine what should be done with this particular fish. Based on the following criteria: Criteria: Length: FISHTYPE - Cat Fish <10:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT