Difference between revisions of "Arrays"

From CompSciWiki
Jump to: navigation, search
Line 1: Line 1:
{{1010Chapter|Introduction=Imagine that you are writing a program that will calculate the average mark of all students in a class.  You know from experience that ''variables'' are used to hold data like a particular students mark.  However, you realize that the class has more than 50 students and so you decide not to use a variable for each individual student.  You know that using a variable for each student is overkill.  Arrays are incredibly useful in this situation.  A variable is a piece of data, whereas an array is simply a list of data.
+
{{1010Chapter|ChapterNum=1
 +
|Introduction=Imagine that you are writing a program that will calculate the average mark of all students in a class.  You know from experience that ''variables'' are used to hold data like a particular students mark.  However, you realize that the class has more than 50 students and so you decide not to use a variable for each individual student.  You know that using a variable for each student is overkill.  Arrays are incredibly useful in this situation.  A variable is a piece of data, whereas an array is simply a list of data.
  
 
With an array you can use a single variable ''student_marks'' to hold '''all''' the marks for each student in the class.  This chapter will cover how to create an array, how to manage data in an array, common errors when using arrays and processing arrays with for loops.
 
With an array you can use a single variable ''student_marks'' to hold '''all''' the marks for each student in the class.  This chapter will cover how to create an array, how to manage data in an array, common errors when using arrays and processing arrays with for loops.
 
I will also have some questions with full program solutions so you can see exactly how arrays can be used.
 
}}
 
  
  
 +
|Body=
 
==[[Creating Arrays]]==
 
==[[Creating Arrays]]==
 
==[[Entering and Using Array Elements]]==
 
==[[Entering and Using Array Elements]]==
Line 13: Line 12:
 
==[[Arrays Review Questions and Exercises|Review Questions and Exercises]]==
 
==[[Arrays Review Questions and Exercises|Review Questions and Exercises]]==
 
==[[Arrays Solutions|Solutions]]==
 
==[[Arrays Solutions|Solutions]]==
 +
 +
 +
|PChapterNum=1
 +
|PChapterLink=[[What Is Programming]]
 +
|NChapterNum=2
 +
|NChapterLink=[[Java Fundamentals]]
 +
}}
 +
 +
 +
{{Category:COMP 1010}}

Revision as of 16:07, 10 August 2010


Wiki 1010 Table of Contents

Chapter 1

Imagine that you are writing a program that will calculate the average mark of all students in a class. You know from experience that variables are used to hold data like a particular students mark. However, you realize that the class has more than 50 students and so you decide not to use a variable for each individual student. You know that using a variable for each student is overkill. Arrays are incredibly useful in this situation. A variable is a piece of data, whereas an array is simply a list of data.

With an array you can use a single variable student_marks to hold all the marks for each student in the class. This chapter will cover how to create an array, how to manage data in an array, common errors when using arrays and processing arrays with for loops.

  Write a Program a Day Case Studies

Creating Arrays

Entering and Using Array Elements

Out of Bounds and One off Errors

Processing Arrays (using for loops)

Review Questions and Exercises

Solutions




Chapter 0: What Is Programming Table of Contents Chapter 2: Java Fundamentals



Template loop detected: