In: Computer Science
needed asap !!!
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.
Error 1:
Line Number: 1
Error description: Used wrong package to import Random class
Statement after correction: import java.util.Random;
Error 2:
Line Number: 3
Error description: Opening Curly Bracket Missing
Statement after correction: public class Sequen {
Error 3:
Line Number: 5
Error description: Semi Colon Missing
Statement after correction: private int stand;
Error 4:
Line Number: 11
Error description: skip is not needed
Statement after correction: nothing
Error 5:
Line Number: 20
Error description: return type of function missing
Statement after correction: public int getStand()
Corrected Program
import java.util.Random;
public class Sequen {
private int stand;
private int calc;
public Sequen(int numStand) {
stand = numStand;
}
public void skip() {
Random sit = new Random();
calc = sit.nextInt(stand) + 1;
}
public int getStand() {
return stand;
}
int getCalc() {
return calc;
}
}