Results 1 to 3 of 3
Thread: Split string using its location
- 02-05-2012, 07:45 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 1
- Rep Power
- 0
Split string using its location
Hi all, I'm quiet new to Java programming, have done a few programs myself. Have a beginers book, and been trying some sample programs in that. But came up with one, that I was wondering how to do a part.
Basically, the program will take an input from the user, that is a string, that in itself includes a workers name, the amount of hours they worked in a given week, and their wage rate. The program, then has to output its pay before taxes and all. This is what the initial string would be like.
Sting numbers 0 - 19 Employees name
20 - 21 Number of hours worked
22 - 25 Hourly rate (Pound and pence)
So an example would be
JohnWaters---------12950
So, the name is John Waters, works 12 hours in the week, and his rate is £9.50 per hour.
I put - in instead of a space just for convienience for people to see clearer.
What I was wondering was is there anyway to take that string, and split it into 3 substrings. I know you can split it, with some deliminater. But can you split a string, based on the amount of characters, if that makes sense.
-
Re: Split string using its location
Why not just use String's substring(...) method?
Last edited by Fubarable; 02-05-2012 at 08:21 PM. Reason: corrected capitalization
- 02-05-2012, 08:17 PM #3
Similar Threads
-
Split a String with split()--Help
By danilson in forum New To JavaReplies: 7Last Post: 11-19-2010, 04:08 PM -
Split string help
By Ben1 in forum New To JavaReplies: 1Last Post: 11-08-2010, 04:28 PM -
String split
By soccer_kid_6 in forum New To JavaReplies: 3Last Post: 10-29-2010, 07:51 PM -
How to split a String using split function
By Java Tip in forum java.langReplies: 4Last Post: 04-17-2009, 08:27 PM -
How to split a String using split function
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:32 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks