In: Computer Science
Identify errors and correct them of the following Java program:
1. import java.utility.Random;
2.
3. public class Sequen
4.
5. private int stand
6. private int calc;
7.
8. public Sequen(int numStand)
9. {
10. stand = numStand;
11. skip;
12. }
13.
14. public void skip()
15. {
16. Random sit = new Random();
17. calc = sit.nextInt(stand) + 1;
18. }
19.
20. public getStand()
21. {
22. return stand;
23. }
24.
25. int getCalc()
26. {
27. return calc;
28. }
29. }
One error is already identified for you as shown below:
Line Number: 5
Error description: Missing semicolon
Statement after correction: private int stand;
Identify 5 other errors and give their Line Number, Error description and Statement after correction.
package linkedList;
import java.util.Random; // Error1: package name util
public class Sequen { // Error2: braces after class name
private int stand; // Error 3: semicolon
missing
private int calc;
public Sequen(int numStand)
{
stand =
numStand;
skip(); //
Error 4: missing paranthesis after skip
}
public void skip()
{
Random sit = new
Random();
calc =
sit.nextInt(stand) + 1;
}
public int getStand() // Error
5: missing return type
{
return
stand;
}
int getCalc()
{
return calc;
}
} // Error 6: remove extra pranthesis
**************************************************
I have tried to answer your question to best of my efforts.
However, if you still face any issues in the answer, please let me
know via the comment section. Your feedback will imporve as well as
encourage me to keep up the good work.
If i was able to help you, then please provide me an
upvote(thumbs up). Thanks!