Hints for lab 3 about working with strings and characters

  1. To get a character, read in a string and then use the charAt() function. See the class example for the exact syntax
  2. 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
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback