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.
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...
Use Java (Geometry: point in a rectangle?) Write a program that prompts the user to enter...
Use Java (Geometry: point in a rectangle?) Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5.  For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle. (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to10 / 2 and its vertical...
JAVA Programming (Convert decimals to fractions) Write a program that prompts the user to enter a...
JAVA Programming (Convert decimals to fractions) Write a program that prompts the user to enter a decimal number and displays the number in a fraction. Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class in LiveExample 13.13 to obtain a rational number for the decimal number. Use the template at https://liveexample.pearsoncmg.com/test/Exercise13_19.txt for your code. Sample Run 1 Enter a decimal number: 3.25 The fraction number is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT