4 Java Question
|
Pg. 01 |
|
Question One |
|
|
|
|
Assignment #3
[Total Mark for this Assignment is 5 points]
IT401
Business Computer Languages
|
|
|
|
|
|
|
|
Question One
2 Marks
Learning Outcome(s):
Ch. (6).
Be able to use common loop algorithms
Be able to program loops with the while and for statements
Question Two
1.5 Marks
Learning Outcome(s):
Ch. (6).
Be able to use common loop algorithms
Be able to program loops with the while and for statements
Write a program in Java to read 5 integers and print and print the minimum and maximum values .Use while loop and if statements in your code. The output of your program looks like:
Question Three
0.5 Marks
Learning Outcome(s):
Ch. (7)
become familiar with using arrays and array lists
What is the value of m after running the following code?
int[] m = new int[8];
m[0] = 1;
for (int i = 1; i < m.length; i++) {
m[i] = m[i-1] + i;
}
Question Four
1 Marks
Learning Outcome(s):
Ch. (7)
Become familiar with using arrays and array lists
Find and fix the error in each of the following codes:
1.
int[ ] a = new int[ 60 ];
for( int h = 0; h <= a.length; h++ )
a[ h ] = 1;
2.
ArrayList m = new ArrayList();
m.add(1);
m.add(2);
m.remove(0);