Question: 5. The following program contains several errors that violate the rules of Java: 1. import java.util.Scanner; 2. public class TimesTable { 3. public static void

5. The following program contains several errors that violate the rules of Java:
1. import java.util.Scanner;
2. public class TimesTable {
3. public static void main(String[] args) {
4. input = new Scanner(System.in);
5. System.out.println("Please input the size of the times
6. + " table: ");
7. int size = input.nextInt();
8. header(size);
9. table(size);
10. }
11. public static header(int size) {
12. System.out.print("* |");
13. for (int i = 1; i
14. System.out.print(" "+i);
15. System.Out.println();
16. for (int i = 1; i
17. System.out.print("-");
18. System.out.println();
19. }
20. public static void table(int) {
21. for (int i = 1; i
22. System.out.print(i+" |");
23. for (int j = 1; j
24. System.out.print(" " + i * j);
25. System.out.println(),
26. }
27. }
28. }
Describe each error and specify whether it is (a) lexical, (b) syntactic, or (c) semantic.
Use the numbers shown to identify the line on which each error occurs. The class may
also contain programming errors that do not violate the rules of Java and will not be
detected by a Java compiler. You should ignore these errors.
 5. The following program contains several errors that violate the rules
5. The following program contains several errors that violate the rules of Java 1. import java.util.Scanner; 2. public class TimesTable ( 3 public static void main(String[ args) 4 input -new Scanner (System.in); System.out.println( "Please input the size of the times 6 +"table:") int size - input.nextInt() header (size); table(size); 10. 1 11. public static header (int size) 12. System.out.print("*\t| " 13. 14. 15. 16. for (int 1-1; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!