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.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.