It is about two dimensional array.
What is two dimensional array??
Let me explain it !
The elements of a 2D array are arranged in rows and columns, and the new operator for 2D arrays specifies both the number of rows and the number of columns.
For example, this creates a 2D array of int that has 12 elements arranged in 3 rows and 4 columns.
Let looks at some question for Lab10.Question 1: Write a program that uses a String array to hold the five students’ names, an array of five characters to hold five students’ letter grades, and five arrays of four doubles each to hold each student’s set of test scores. The program should have methods that return a specific students’ name, average test score, and a letter grade based on the average.
**Several method is invoked or called which are getName(). getScore(), getTotal(), getAverage() and getGrade()
The name of students is stored, followed by their scores for four test and total. Next, the average is counted and last but not least grade is determined based on the average.
Question 2 : Write the following method that returns the location of the largest element in a two dimensional array.
public static int[] locateLargest(double[][] a)
The return value is a one-dimensional array that contains two elements. These two elements indicate the row and column indices of the largest element in the two dimensional array. Write a test program that prompts the user to enter a two-dimensional array and displays the location of the largest element in the array.
**First row and column is entered and their elements are entered by user.
The largest element is found using loops.
It quite complicated, but with the helps of friends I am able to solve it. Thanks them very much.
Question 3 is asked to (a)find the smallest number and (b) print a reverse of the array by considering the program given.
(a) The smallest number is found by using usual way.
(b) I am still finding the way to solve this.
This question is asked us to write a program that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program will generate number randomly between 1 and 100; then produce a chart similar to the one below indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered.
The answer is as following :
* This question is solved by using array and loops.
The histogram is constructed by printing "*" in cmd. The numbers is entered until the number entered is not in range 1-100. If number is out of 1-100, the program will end and the histogram is displayed.
The "*" print out in which rows is depend on the numbers entered.
Let's do a summary for the lecture from week 1 to14. It's a wonderful class we attended. We have a very good and kind lecturer named En. Erzam. He always like to make joke in class and taught us step by step.
Through this course, we are able to know what is programming. Every program does not come easily and successful without a good programming.
In short, what we learned throughout these 14 weeks is selection, loops, method, string and array. We learned one by one. Firstly, we know how to solve selection problem. Next, we know how to use loop to do repetition. Thirdly, we know how to call or invoke method to make programming easily. Moreover, we know how to use string in constructing the code. Last but not least, array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
I am very happy and satisfied because I get such amazing knowledge and hope to explore in future.
That's all for our lab. Good luck and all the best to our final.^^
Thank you very much ! Byeeee ^^
LIM XUE TING
183615
SSK3100
(Group15)
Next blog: hennyabigail.blogspot.com (Henny
Abigailwillyen Sinjus)