Tsa1 Macasaet
Tsa1 Macasaet
CCS0023L
(Object Oriented Programming)
EXERCISE
4
Declaring Arrays
Section:
Professor:
I. PROGRAM OUTCOME/S (PO) ADRESSED BY THE LABORATORY EXERCISE
a. Apply knowledge of computing appropriate to the discipline.
Array is a sequence of objects of the same type and packaged together under one identifier name. The
first element in an array is at position zero: array [0]. There are three steps to create an array:
Declaration, Construction and Initialization.
Declaring one-dimensional
data_type name_of_array[integer_expression];
Example:
Example:
Array Controlling
V. EXPERIMENTAL PROCEDURE:
1. Create a program that will store student information in two dimensional array
studentarr[3][3], the program should be able to display the names of the students
and their corresponding grades and averages.
Studentarray[3][3]={{“peter”, 75,77},
{“clark”, 78, 80},
{“logan”,82,84}};
public class Main
{
public static void main(String[] args) {
String Studentarray[][] =
{{"Peter", "75", "77"},
{"Clark", "78", "80"},
{"Logan","82","84"}};
System.out.println("Student Array: \n");
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
System.out.print(Studentarray[i][j] + " ");
}
System.out.println(" ");
}
}
}
1. Why is it necessary, being a programmer, to use arrays?. What are the risks of not using
arrays?
it is necessary and most convenient type of control structure to use is the IF-ELSE structure.
Mainly because, if-else involves just little amount of declaration and variables needed to run
your program. It is more convenient because it gives you the proper options in what you are
trying to execute so that you will not miss a single thing that you need
the easiest strategy in doing loop statements is the do while. Mainly because it is easier to code
rather than other looping statements. Do while statements tend to help you to really understand
how your program will run properly and effectively, that`s why like to use this statement often.
Note: The following rubrics/metrics will be used to grade students’ output in the lab
Exercise 2.
Topic Arrays
Lab Activity No 4
Lab Activity Declaring Arrays
CLO 2
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL