Go Back   Velocity Reviews > General Computer Discussion > General Help Related Topics
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

General Help Related Topics - Java String Problems

 
Thread Tools Search this Thread
Old 02-03-2009, 11:02 PM   #1
Default Java String Problems


Can anyone help me? I am a beginning Java programmer, and I can't figure out how to do the following.:


Write a program names L5GetName where the user enters a String. The string contains the users first name and last name separated by one of more spaces. Output the name as last name, first name. Capitalize the first letter of each name. The following is sample output that you can use to test your program. Note the case that should detect an error.

Input Output
john doe Doe, John
mary Lamb Lamb, Mary
bob Error: must have first and last name
BOB HOPE Hope, Bob
mary lamb Lamb, Mary

Note: Your program should be in a loop so that when the user clicks cancel, the program exits. It exits the loop when IO.inputString() returns a null.
Note: Make sure to include your name, date, purpose of the program, and the name of the source file as comments at the top.
Hint: For this lab, use of the following string methods is sufficient: equals, substring, indexOf, length, toUpperCase, toLowerCase, trim and string concatenation.


Write a program named L5GetString that accepts a string and outputs:

a. The string
b. Count the number of vowels in the string
c. The offset to the first occurrence of a vowel
d. A string that replaces all occurrences of the first letter of the input string by the second letter of that string.


Note: Like the previous example, exit the program when the user clicks cancel while entering the string. Include your name, date, and name of the source file as comments at the top.
Hint: For this lab, use of the following string methods is sufficient: charAt, indexOf, length.

Sample input and output

The string is abracadabra
Count of vowels is 5
Index of first vowels is 0
The replacement string is bbrbcbdbbrb

The string is sississippi
Count of vowels is 4
Index of first vowels is 1
The replacement string is iiiiiiiippi



Thanks,

Bobby


rbnbenjamin
rbnbenjamin is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Give you enough string functions in Java web reporting tool freezea Software 0 10-08-2009 09:03 AM
ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method) msandlana Software 0 04-25-2008 06:37 AM
Hidden linebreaks in string? VB.NET Jiggy Software 0 04-23-2008 02:18 PM
Re: Pioneer DVR-105 and Nero Problems grams@oldtown.com DVD Video 1 08-12-2003 04:17 AM
Re: Pioneer DVR-105 and Nero Problems Ron DVD Video 1 08-08-2003 06:33 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46