cs 2430 day 1. agenda load netbeans introduction syllabus review some array operations

22
CS 2430 Day 1

Upload: dortha-georgina-mosley

Post on 02-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

CS 2430

Day 1

Page 2: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

Agenda

• Load NetBeans

• Introduction

• Syllabus

• Review some array operations

Page 3: 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

Page 4: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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)

Page 5: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

Course homepage

http://www.uwplatt.edu/csse/Courses/CS243

Page 6: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

Course work

3 exams (60 points each) 180

Final exam 100

6 quizzes (drop lowest quiz) 50

Programs and labs 170

___________________________________

TOTAL 500

Page 7: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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

Page 8: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

Syllabus

• Read the rest of the syllabus on your own time!

Page 9: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

Any questions?

Page 10: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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

Page 11: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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!

Page 12: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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

Page 13: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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

Page 14: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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!

Page 15: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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;

}

Page 16: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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

Page 17: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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);

Page 18: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

Any questions?

Page 19: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

Go to:

https://xray.ion.uwplatt.edu/summerss

Page 20: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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!)

Page 21: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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

Page 22: CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations

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