Computer Science, asked by arudra1030, 7 months ago

Write a Java program to accept your name and print the 4th character.

Answers

Answered by Anonymous
2

Answer:

Explanation:

We need to use the next() method to read a single character as a string and then use charAt(0) to get the first character of that string. Scanner scanner = new Scanner(System.in); char ch = scanner. next(). charAt(0);

Please mark me as brain list  

BY Tolety Roshan  

Answered by pandacorn327
0

Get first 4 characters of String – Examples

Exercise 2.6:

This exercise asks you to write a program that tests some of the built-in subroutines for working with Strings. The program should ask the user to enter their first name and their last name, separated by a space. Read the user's response . Break the input string up into two strings, one containing the first name and one containing the last name. You can do that by using the  to extract each of the two names. Also output the number of characters in each name, and output the user's initials. (The initials are the first letter of the first name together with the first letter of the last name.) A sample run of the program should look something like this:

Please enter your first name and last name, separated by a space.

? Mary Smith

Your first name is Mary, which has 4 characters

Your last name is Smith, which has 5 characters

Your initials are MS

Hope it helps

Have a great day

Keep smiling thank you very much sir/ma'dam

Similar questions