How many lexemes does the following Java code contain 1 publ

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.

Solution

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.

How many lexemes does the following Java code contain? 1. public class CountDigits { 2. public static void main(String[] args) { 3. SimpleIO.prompt(\
How many lexemes does the following Java code contain? 1. public class CountDigits { 2. public static void main(String[] args) { 3. SimpleIO.prompt(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site