English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do you write this program?

The calling program prompts the user for his/her name in capital letters. Write a program which prompts the user for the input and then calls a method to return the name with only the first letter capitalized. You may assume in this case that the user has given you valid input.

Sample input: DEENA
Sample output: Deena

2007-12-19 06:24:40 · 4 answers · asked by premevil666 1 in Computers & Internet Programming & Design

4 answers

Using inStr to represent your valid String input value...

String capStr = inStr.substring(0,1).toUpperCase() + inStr.substring(1).toLowerCase();

2007-12-19 06:34:47 · answer #1 · answered by richarduie 6 · 1 0

No homework questions, please!

Here's some hints, though...

Look up the java string methods (java.lang.String)
See if there's some useful methods there. (there will be)
You'll want methods to extract a character from a string, and to convert a character or string to uppercase and / or lowercase.

Hope this helps!

2007-12-19 14:34:32 · answer #2 · answered by Anonymous · 0 0

Easy enough...

Create a String object; call it "s"
Accept the input as a string.
Create another String object; call it "d"
d = ( s.substring(0,1)).toUpperCase() + ( s.substring(1)).toLowerCase();

2007-12-19 14:42:13 · answer #3 · answered by jgoulden 7 · 0 0

im assuming you use string lengths and charval...not sure if i was talking about basic or java

2007-12-19 14:31:11 · answer #4 · answered by bryant s 4 · 0 0

fedest.com, questions and answers