cs 2430 day 1. agenda load netbeans introduction syllabus review some array operations
TRANSCRIPT
CS 2430
Day 1
Agenda
• Load NetBeans
• Introduction
• Syllabus
• Review some array operations
Contact information
• Name: Scott Summers
• Email: [email protected]
• Web: http://www.uwplatt.edu/~summerss
• Phone: 608-342-1516
• Office: Ulrich 214
• Office hours: See “schedule” on my webpage
About me
• Starting fifth semester at UW—Platteville
• Education:
– BS: UW-Green Bay, 2004
– MS: Iowa State University, 2007
– PhD: Iowa State University, 2010• Studied theory of computation• ISU: home of the first (non-programmable)
electronic digital computing device• Atanasoff-Berry Computer (ABC)
Course work
3 exams (60 points each) 180
Final exam 100
6 quizzes (drop lowest quiz) 50
Programs and labs 170
___________________________________
TOTAL 500
Grading scaleCourse Grade Points Percentage Grade PointsA 460 - 500 92% 4.0A- 445 - 459 89% 3.7 B+ 430 - 444 86% 3.3B 410 - 429 82% 3.0B- 395 - 409 79% 2.7C+ 380 - 394 76% 2.3C 360 - 379 72% 2.0C- 345 - 359 69% 1.7D+ 325 - 344 65% 1.3D 300 - 324 60% 1.0F below 300 0.0
Syllabus
• Read the rest of the syllabus on your own time!
Any questions?
CS 243 versus CS 143
CS 143:
• C++
• HiC
CS 243:
• Java
• NetBeans 7.1.2
• All methods, including “main()”, are contained inside of classes
Java and NetBeans
• How to create a new project? (Lab 1)
• Uncheck “Set As Main Project”
• Uncheck “Create Main Class”
• The filename is case sensitive
• Mind the location!
Transition from C++ to Java
• If you know C++ syntax, then you will find Java syntax familiar
• You already know how to do a lot of stuff in Java such as– Declare variables– Write loops– Process (but not declare) arrays– Call methods
Primitive data types
Type Size (bits) Default value
char 16 ‘\u0000’
int, short, long 32, 16, 64 0, 0, 0L
float, double 32, 64 0.0f, 0.0d
boolean ??? false
byte 8 0
Some syntaxint value, total = 0, rem, quot;
value = 5;
if (value > 0)
total += value;
else
{
rem = value % 5;
quot = value / 5;
}
// Declaration statement
// Assignment statement
// Conditional statement
// Braces needed for statement
// block
Is this Java or C++ code?
It’s both!
A while loop in C++int count = 0, total = 0;
while (count < 100)
{
++count; // performs the increment before doing
// anything else (highest precedence), same
// as "count++" in this case
total += count;
}
A while loop in Javaint count = 0, total = 0;
while (count < 100)
{
++count; // performs the increment before doing
// anything else (highest precedence), same
// as "count++" in this case
total += count;
}
No difference!
Same with “for” loops—Java and C++ have same syntax
Input and output
C++cin >> value;
cout << "The value: " << value;
cout << "The value: " << value << endl;
Java// We will discuss input later in the course!
System.out.print("The value: " + value);
System.out.println("The value: " + value);
Any questions?
Review array operations
Do you remember how to do these?
• Declare an array
• Add to the end
• Delete and maintain relative order
• Delete and do not maintain relative order
• Linear search
• Mean (average)
• Sort (discussed later in the course!)
Array organization
C++
int intArray[50];
// Array of size 50
// Indexed from 0 to 49
Java
// Array is a class in Java
int [] intArray;
// int[] intArray;
// int intArray[];
// To get an array object, use
// the new keyword (literally!)
intArray = new int[50];
intArray ∙ ∙ ∙
0 1 482 49
50
Array declarationfinal int MAX_SIZE = 10; // same as const from C++
int xVal, size = 0;int intArray[];
intArray = new int[MAX_SIZE]; // could use a non-constant variable
// intArray: array of integers// MAX_SIZE: the maximum number of values of intArray// size : the actual number of values of intArray
int len = intArray.length; // no ()'s // returns the length of the array, // NOT the number of elements in the // array