Results 1 to 3 of 3
- 02-05-2012, 08:45 PM #1Member
- Join Date
- Feb 2012
- Rep Power
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
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 09:21 PM. Reason: corrected capitalization
- 02-05-2012, 09:17 PM #3
- By danilson in forum New To JavaReplies: 7Last Post: 11-19-2010, 05:08 PM
- By Ben1 in forum New To JavaReplies: 1Last Post: 11-08-2010, 05:28 PM
- By soccer_kid_6 in forum New To JavaReplies: 3Last Post: 10-29-2010, 08:51 PM
- By Java Tip in forum java.langReplies: 4Last Post: 04-17-2009, 09:27 PM
- By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 10:32 PM