Basic String Help
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!
Why do you need them split?
Surely you can simply ask the user to enter their license plate number, and use nextLine() to read it in?