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 (name it InputSum) that prompts the user to enter positive integer numbers...
Write a Java program (name it InputSum) that prompts the user to enter positive integer numbers using a sentinel while loop. The program should accept integer inputs until the user enters the value -1 (negative one is the sentinel value that stops the while loop). After the user enters -1, the program should display the entered numbers followed by their sum as shown below. Notice that -1 is not part of the output. The program should ignore any other negative...
Write a java program that prompts user to enter his name and KSU ID using format...
Write a java program that prompts user to enter his name and KSU ID using format name-ID as one value, his gender as char, and his GPA out of 5. Then your program should do the following: Print whether the ID is valid or not, where a valid ID should be of length = 9, and should start with 4. Calculate the GPA out of 100 which is calculated as follows GPA/5 * 100. Update the name after converting the...
JAVA Write a program that will compare two names. The program prompts the user to enter...
JAVA Write a program that will compare two names. The program prompts the user to enter two names for a comparison. If the names are same, the program states that. If the names are different, the program converts both names to UPPERCASE, and compares then again. If they are equal, the programs displays a message stating that names are equal if CASE is ignored. Otherwise, the program prints names with a message that names are not equal.  Check also if there...
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 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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT