Answered You can hire a professional tutor to get the answer.

QUESTION

The following program contains several errors that violate the rules of Java: public class writeSequence{ 2. public static void main(String[ args){...

The following program contains several errors that violate the rules of Java: 

1. public class writeSequence{ 

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

3. writeSequence(5.3); 

4. } 

5. pulbic static void writeSequence(int x){ 

6. if(x==1){ 

7. System.out.print("1"); 

8. } 

9. else if(x=2){ 

10. System.out.print("1 1"); 

11. } 

12. else if(x%2==0){ 

13. System.out.print((x/2) + " ); 

14. writeSequence(x-2); 

15. System.out.print(" " + (x/2)); 

16. } 

17. else if(x%2 == 1 ){ 

18. System.out.print(((x+1)/2) + " "); 

19. writeSequence((x-2)); 

20. System.out.print(" " + ((x+1)/2)); 

21. } 

22. } 

23. } 

Locate all the errors and specify whether each one is (a) lexical, (b) syntactic, or (c) semantic. Use the numbers shown to identify the line on which each error occurs. The program 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. 

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question