Hints for lab 3 about working with strings and characters
- To get a character, read in a string and then use the charAt() function. See the class example for the exact syntax
- It is best in this lab to do keyboard.nextLine() after any keyboard.nextDouble() if one is getting a string after a double. This is important to "eat" the end of line character after the double before getting the string on the next line of input. Example:
number = keyboard.nextDouble();
keyboard.nextLine();
...
str = keyboard.nextLine();
This topic: CenterForComputing
> WebHome >
Syllabi >
SyllabiFall2024 >
CSC121SylF2024 >
CSC121F2024Lab03 > CSC121F2024Lab03Hint04
Topic revision: r1 - 2024-06-10 - CathyBareiss