Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How many lexemes does the following Java code contain? 1. public class CountDigi

ID: 3788139 • Letter: H

Question

How many lexemes does the following Java code contain?

1. public class CountDigits {

2. public static void main(String[] args) {

3. SimpleIO.prompt("Enter an integer: ");

4. String userInput = SimpleIO.readLine();

5. int number = Integer.parseInt(userInput);

6. int numDigits = 0;

7. while (number > 0) {

8. number /= 10;

9. numDigits++;

10. }

11. System.out.println("The number " + userInput + " has " +

12. numDigits + " digits");

13. }

14. }

Give the number of lexemes on each line (using the line numbers shown) as well as the total number of lexemes.

Explanation / Answer

Line number     Number of lexemes

1                            4

2                            11

3                            12

4                            9

5                            10

6                            5

7                            7

8                            5

9                            3

10                           1

11                           17

12                           7

13                            1

14                            1

Total number of lexemes is 93.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote