Write a program to prompt the user to enter a name and store it in a String variable (you may assume the name is input in the form: firstname secondname,

computer science

Description

6.    Allow the user to input a word

(a)  Display the first character of this word

(b)  Display the 5th character of this word

(c)  Display the last character

(d)  Display the word

i.    with the first character removed

ii.   in sentence Case (i.e. first letter in capitals, rest in lower case)

iii.   with the first 2 characters replaced with “XX”

iv.   with the last character removed

(e)  Check if the word contains “  ” (a space), and if so, display “Space here”; otherwise display “No space”

(f)  Check if the word starts with “e”, and if it does, show the word with the “e” capitalized.

(g)  **Check if there is an odd number of letters in the word, and if there is, print out the middle one.

 

7.    Write code to determine if a phrase contains the word ‘no’ (in either upper or lower case).

 

8.    A product code has 3 digits, 2 letters in the middle and then 2 digits – e.g. 537GR23.  Write code to display (for any product code with this layout)

•     the initial 3 digits,

•     the 2 letters

•     the final 2 digits.

9.    Write a program to prompt the user to enter a name and store it in a String variable (you may assume the name is input in the form: firstname  secondname, all lower case e.g. – tom fox).  Then write the code for each of the following:     

(a)   Output the second name followed by the first name. 

(b)   Output the user name vertically on the screen (Hint: user charAt())

t

o

m

 

f

o

x

 

 

(c)    Output the user’s name in uppercase.

(d)   Output the user’s initials in uppercase.
How would this change if user gives fullname as: tom joe fox ***

(e)    Compute and output the frequency of the letter ‘o’ in the name.

f)     Compute and output the frequency of any particular letter in the name – prompt for entry of the letter.

 


Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.