Results 1 to 2 of 2
Thread: Basic String Help
- 11-15-2010, 05:04 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 1
- Rep Power
- 0
Basic String Help
Hello Everyone!
I am currently working on a lab for APCS and needed some guidance on Strings.
The lab asks for a license plate to be inputed by the user, and I am asked to add up the ASCII values of the letter part of the plate to the number part.
Here is what I have so far:
System.out.print("Please enter the 'AAA' of your license plate: " );
plate1 = in.next();
System.out.print("Please enter the '###' of your license plate: ");
plate2 = in.nextInt();
for (int i=0; i < plate1.length(); i++)
{
char c = plate1.charAt(i);
int j = (int) c;
total1 += c;
}
total2 = total1+plate2;
Obviously this is not my entire code, however I was wondering how I could make the user simply input the license plate in one line. I tried using the substring method, but got no luck.
Basically I need assistance on taking the AAA value of the plate, finding the ASCII and adding it to the ###. Instead of taking the ASCII of the ### portion too. So I would like to be able to have the user enter AAA### on one line.
Thanks for the help!
- 11-15-2010, 10:50 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Basic GUI help
By vahshir in forum New To JavaReplies: 5Last Post: 10-11-2010, 01:33 AM -
Need really basic help!
By anthonyalaan in forum New To JavaReplies: 9Last Post: 09-12-2010, 01:43 PM -
String Tokenizer - Basic email validation
By bobbyboyy in forum New To JavaReplies: 3Last Post: 11-01-2009, 04:44 PM -
Basic Help
By robjames in forum New To JavaReplies: 3Last Post: 02-09-2009, 02:58 AM -
Need some really basic help
By Mayur in forum New To JavaReplies: 6Last Post: 01-24-2009, 06:00 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks