+ 4

Number of letters in strings

Hi guys! I have a problem with my program. What I need to do is ask the user to enter his full name(First, Middle, Last) and store it in one string - this I managed to accomplish. Then it has to print the number of characters in the name not counting spaces -here I have problems. Then determine and print the three parts of the full name and the number of characters in each. And worse part: determine and print the initials in ASCII codes (decimal) for the full name. Here is what I have so far: https://code.sololearn.com/cBY3W0hY5ujX I'm a complete beginner in Java, and I have to make an assignment for the chapter that we didn't pass yet because I'll be in a hospital next two weeks(heart condition, high BP) and this is my only chance to don't fail the course. Professor offers me to drop it, but I can not afford to pay for it again. Any help is much appreciated!

25th Jan 2018, 12:44 AM
DIY Mods
DIY Mods - avatar
6 Respostas
+ 19
//create variable x , initialize it with 0 run a loop 3 times & take user input as a word , print the word , its length & first character (use charAt(0) ) & also add the length of word to x each time now when loop gets over , print x as the no. of characters in name without spaces
25th Jan 2018, 5:23 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
I do
25th Jan 2018, 2:31 AM
DIY Mods
DIY Mods - avatar
+ 1
Thank you so much for your answer! Noob question: I'm trying to use scanner to prompt the user for input instead of given string that you used, but it gives me an error after first name: Enter your full name: John Bon Jovy Full Name: John First Name: John 4 chars. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at assignment4.FuName.FullName(FuName.java:29) at assignment4.FuName.main(FuName.java:8) P.S. I need to convert it to ASCII instead of Unicode
28th Jan 2018, 5:50 AM
DIY Mods
DIY Mods - avatar
+ 1
P.S. how can I convert it to ASCII not Unicode? Thank you in advance. You are really helpful!
28th Jan 2018, 5:53 AM
DIY Mods
DIY Mods - avatar
+ 1
I found it already. Just need to cast it to int. Thanks a lot! you are the best!)
28th Jan 2018, 6:13 AM
DIY Mods
DIY Mods - avatar
0
I think I shouldn't use a loop because the name has to be entered in one string. That's why I have a problem. Some pseudocode would be wonderful and much appreciated.
25th Jan 2018, 5:48 PM
DIY Mods
DIY Mods - avatar