CS 117 Spring 2002 IDAHO TRANSPORTATION DEPARTMENT Internship Announcement POSITION TITLE: Computer Science Intern JOB DESCRIPTION: Translate technical.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Programming Languages and Paradigms The C Programming Language.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
True or false A variable of type char can hold the value 301. ( F )
Chapter 14: Overloading and Templates C++ Programming: Program Design Including Data Structures, Fifth Edition.
Chapter 10.
Primitive Variable types Basic types –char (single character or ASCII integer value) –int (integer) –short (not longer than int) –long (longer than int)
CS 117 Spring 2002 Basic Program Elements Chapter 2.
Chapter 5: Loops and Files.
Arrays Hanly - Chapter 7 Friedman-Koffman - Chapter 9.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
More Arrays Arrays and classes Multi-dimensional Arrays Dynamic arrays.
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
Chapter 9: Arrays and Strings
CS 117 Spring 2002 Decision Making Hanly Chapter 3 Friedman-Koffman Chapter 4.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Chapter 8 Arrays and Strings
Chapter 4 Making Decisions
Introduction to C Programming
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
Chapter 15: Operator Overloading
CS 117 Spring 2002 Review for Exam 3 arrays strings files classes.
Review of C++ Programming Part II Sheng-Fang Huang.
Expressions and Interactivity Chapter 3. 2 The cin Object Standard input object Like cout, requires iostream file Used to read input from keyboard Often.
Stream Handling Streams - means flow of data to and from program variables. - We declare the variables in our C++ for holding data temporarily in the memory.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Chapter 8 Arrays and Strings
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 12: Pointers continued, C strings.
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
C++ for Engineers and Scientists Second Edition Chapter 8 I/O File Streams and Data Files.
File I/O ifstreams and ofstreams Sections 11.1 &
CS Midterm Study Guide Fall General topics Definitions and rules Technical names of things Syntax of C++ constructs Meaning of C++ constructs.
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 3 Expressions and Interactivity.
Data Types Declarations Expressions Data storage C++ Basics.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
12/15/2015Engineering Problem Solving with C++, Second Edition, J. Ingber 1 Engineering Problem Solving with C++, Etter Chapter 6 One-Dimensional Arrays.
Chapter Making Decisions 4. Relational Operators 4.1.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 4 Making Decisions.
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
Loops and Files. 5.1 The Increment and Decrement Operators.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 1 due Friday, 7pm. RAD due next Friday. Presentations week 6. Today: –More details on functions,
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 5 Looping.
Lecturer: Nguyen Thi Hien Software Engineering Department Home page: hienngong.wordpress.com Chapter 2: Language C++
Extra Recitations Wednesday 19:40-22:30 FENS L055 (tomorrow!) Friday 13:40-16:30 FENS L063 Friday 17: :30 FENS L045 Friday 19:40-22:30 FENS G032.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 11: Pointers.
CPS120 Introduction to Computer Science Exam Review Lecture 18.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
Chapter Expressions and Interactivity 3. The cin Object 3.1.
Chapter 4: Introduction To C++ (Part 3). The cin Object Standard input object Like cout, requires iostream file Used to read input from keyboard Information.
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3: Expressions and Interactivity.
Windows Programming Lecture 03. Pointers and Arrays.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
Bill Tucker Austin Community College COSC 1315
Java Primer 1: Types, Classes and Operators
Programming Languages and Paradigms
The Selection Structure
Programming Paradigms
Introduction to C++ Programming
Chapter 3: Input/Output
Chapter 2: Introduction to C++.
Programming Languages and Paradigms
Presentation transcript:

CS 117 Spring 2002 IDAHO TRANSPORTATION DEPARTMENT Internship Announcement POSITION TITLE: Computer Science Intern JOB DESCRIPTION: Translate technical manuals into HTML format for accessibility via Internet. Develop WEB page for the Highway Maintenance section information on ITD’s home page. Miscellaneous work would primarily involve writing code for Access databases for various computer programs.

CS 117 Spring 2002 IDAHO TRANSPORTATION DEPARTMENT Internship Announcement HOURS: FLEXIBLE up to 20 hours per week REQUIREMENTS: Computer Science student or a closely related field COMPENSATION: $10.00 per hour FOR MORE INFORMATION CONTACT: Bryon Breen or

CS 117 Spring 2002 IDAHO TRANSPORTATION DEPARTMENT Internship Announcement HOW TO APPLY: Send Resume to: Bryon Breen Idaho Transportation Department Maintenance Section 3311 W. State Street P.O. Box 7129 Boise, ID APPLICATION DEADLINE: Open until filled.

Review for final May 15 8:00-10:00 in ET 103 comprehensive Open book –2 pages of notes which will be turned in with the final

Material Covered Hanly: Chapters 1-10 Friedman-Koffman: Chapters 1-5, , , 8, , , 11.7, 13.1

Types intwhole number1 doublereal or floating point numbers e-3 charsingle character'a' '\n' boollogical typetrue or false class typesbuilt-in and user definede.g. string arraycollection of same type

Variable Declarations set aside memory to store and retrieve information –type varName int i; double x, y; –can be initialized when declared char quit = 'q'; –can be declared constant const double PI = ;

Operators + addition -subtraction, negation (unary) *multiplication /division –integer division discards remainder % modulus (int only)

Expressions Combination of variables and operators a a + b a + b * c type of expression determined from type of operands –int for two integers –double for one or two doubles

Evaluation of Expressions Done one operand at a time based on precedence type of a sub-expression depends only on the operands in the sub-expression, not on those in the entire expression int i, j; double x, y; y = i / j + x * i;

Precedence parenthesized expressions unary operators: - ! * / % + - (binary) comparisons >= == != && || =

math.h Collection of mathematical functions –sqrtsquare root –sin, cos, …trig functions –exp(x)e x –log, log10log functions –pow(x, y)power x y –abs, fabsabsolute value

Selection and repetition Selection - select between several alternative blocks of code –if –switch Repetition - repeated execution of block of code –while –do-while –for

Boolean Expressions needed for both selection and repetition don't confuse == with = a==b has value of either true or false a=b has same value as b de Morgan's laws !(p && q) == !p || !q !(p || q) == !p && !q

Boolean Operators comparison operators - boolean result => == != unary !logical NOT binary operators &&logical and ||logical or short circuit evaluation

if..else if (condition) thenDoThis; else doThat; thisAlwaysDone; body of if and else one statement unless { } used

Multiple if statements Sometimes there are more than two cases. if (condition) thenDoThis; else if (condition2) doThat; else if (condition3) … else doInAllOtherCases; thisAlwaysDone;

format of switch switch (variable) { case value1: Action1; break; case value2: action2; break; default: // if no other case holds default action; } variable must be discrete type (int, char) The first case for which variable has the value given in the case is executed break forces exit from the switch statement withoutbreak, execution falls through to next case

Loops while condition test precedes each loop repetition loop body may not be executed while (condition) dothis; for –compact form of while for (initialization; condition; modification) doSomething; do-while use when at least one repetition of loop body must be ensured test condition after execution of body do that; while (condition);

Functions self-contained block of code that can be called from different places in a program parameters used to pass information to the function return sends information back to the caller main is a function

Declaring a function double someFunction( int param1, int param2); return type is double. –return type can be any type, either built-in or a class type –If nothing is to be returned, return type should be void. The function name is someFunction. The parameter list is contained within the parentheses. –There can be any number of parameters, including 0. –The function parameters are places to store the values that are passed in.

Calling a function You call a function by giving its name followed by a list of arguments in parentheses. double x = someFunction( arg1, arg2); double y = sqrt( 2.54); The list of arguments should match the function's parameter list in number of arguments and type. arg1 and arg2 may be variables, numbers or expressions. They are evaluated and the values stores in the corresponding function parameters.

Function Definition The function definition contains the code that is executed when the function is called. double someFunction( int param1, int param2) { // code that is executed return aDouble; // required for function that returns a value } Note: param1 and param 2 are declared in the function signature; don't redeclare them or they will be hidden by the newly declared variables.

Value and Reference Parameters by default function arguments are passed by value –function gets the value of the parameter to store in the formal parameter –they can't be changed by the function reference parameters have a & between the type and the argument name void swap( int & a, int & b); –Reference parameters can be changed by the function.

Arrays a collection of values/objects of the same type –they can be of any type int values[20] –sets aside memory for 20 integers The elements are accessed by putting the index of the element in square brackets, e.g. values[3] For an array declared to have n elements, the array index runs from 0 to n-1 –You have to keep track of how many of the array elements have been assigned values.

For arrays, know how to declare an array int score[30]; initialize an array when it is declared double x[ ] = {1.9, 2.8, 3.7, 4.6, 5.5}; access an element of the array score[3] –first element has index 0

Array know how cont. use a loop to do something with every element of the array for (int i=0; i<numElements; i++) sum = sum + score[i]; pass the entire array to a function highScore = max( score, nstudents);

Declaring 2-D arrays similar to one dimensional arrays. int matrix[8][6]; –declares an 8 by 6 array of ints, i.e. an array of 8 6-element arrays char wordList[10][20]; –declares an array of 10 cstrings, each of which can have 19 characters

String Know-how C-style C++ string declarechar cstr[6];string str; initializechar dstr[] = "cat"; char [4] estr="top"; string str1="bat"; string s2("man"); get lengthstrlen( cstr)s2.length() get element i cstr[i]s1[i] s2.at(i)

string.h strlen - returns number of characters in the string –doesn't count the null character –strlen(dstr) will return 3 strcpy - to copy a string into another one –strcpy( cstr, "man") will put man into cstr strcat - to append one string onto another –strcat( dstr, cstr) puts "batman in dstr strcomp - for comparing two string: –returns 0 if they are the same –strcomp( dstr, cstr) will be non-zero –strcomp( cstr, "man") will return 0

C++ string class An object-oriented way to work with text strings #include most operators are defined –input a string with >> output a string with << –assign a value using = str1 = "one"; –compare using familiar operators str1 == str2 str2 < str1 –concatenate with + str1 + str2

reading with >> cin >> word => word = Now cin >> word => word = is

reading with getline getline( cin, line) => line = " the time " getline( cin, line) => line = " for all good men"

Pointer Variables int * iptr; declares a variable that holds the address of an int; memory is allocated for the address (pointer) but not the int get memory with new iptr = new int; or assign to address of existing int iptr = & i;

Pointers and Dynamic arrays A dynamic array is declared as a pointer int * iArray; use new to allocate appropriate amount of memory iArray = new int[ desiredSize]; use iArray just like you use any array iArray[index] = someValue;

Input and Output include iostream input –cin is standard input stream - keyboard –>> extracts data from input stream and stores in variables output –cout is standard output stream - monitor screen –<< inserts data into the output stream

File I/O #include classes –ifstream for input –ofstream for output Constructors –default –initializing takes c-string filename

File I/O functions you should know how to use –open( char filename[]) –eof() - to test for end of file –fail() - to test for all errors –close() read/write the same as for cin/cout

iomanip setiosflags(ios::flagname) resetiosflags(ios::flagname) –right / left –fixed –scientific –showpoint setw( int fieldwidth) setprecision( int digits)

Class Declaration what member variables are needed –data needed to represent the object what functions are needed –functions represent behavior and/or services

Form of declaration class aClass { public: aClass();// zero parameter constructor aClass( int v1, double v2); int getVar1() const; // accessors void setVar2( double d); // mutator functions private: int var1; double var2; friend operator<<( ostream &, const Angle &); };

Member and friend functions constructors used to initialize objects –name of constructor is same as the class name member functions –accessors provide read-only access to member variables –mutators allow user to change member variables –friend functions other associated functions –overloaded operators provide arithmetic and/or comparisons in same ways as for numbers –friend functions allowed access to the private members of the class

Member Function Definitions The function definition contains the code that is executed when the function is called. double aClass::memberFunction( int param1, int param2) { // code that is executed return aDouble; } scope resolution operator: aClass:: indicates to the compiler that this is a member function of class aClass

Declaring Objects You declare an object by giving the className (its type) and a variable name. theClass obj1; This calls the zero parameter constructor You can initialize an object when you declare it by providing arguments theClass obj2( 12, 3.4); This calls a constructor which has int and double parameters.

Calling member functions From outside the class, you call a member function using the. operator double x = obj1.someFunction( arg1, arg2); Inside the class, only need the. operator for an object other than the current one You use overloaded operators the same way you always use operators: obj1 < obj2; cout << obj1;

Things to remember member variables should not be passed to member functions –these functions already have access to them all class members are private unless they appear in the public section of the class definition –private members are not directly accessible from outside the class don't redeclare the member variables –they are declared in the class declaration member functions that use only member variables need no parameters

Hanly Review Problems ChapterPagesExercises ,

Hanly Review Problems ChapterPagesExercises , 5 2

Hanly Review Problems ChapterPagesExercises , 5 2

Hanly Chapter 5p 165 p 179 p 185 p Chapter 6p 226 p 230 p 239 #1, 2 #10 #2, 4

Hanly Review Problems Chapter 7p 278 p 289 p P 303 #2 # 1-2 Chapter 9p 384 p 387 #1

Friedman-Koffman Review Chapter 2:Page 48 problems 1, 3; Page 56 problems 3-5; Page 65 problems 1, 3, 4; Page 81 problems 2, 5-7; Page 93 Quick Check 1-5; Page 95 questions 2, 4, 7, 8, 11, 12 Chapter 3: Page 118 problem 1; p 119 #1, p 142 #1, p 154, #2-3; p 165 #10 (just write the functions) Chapter 4: Page 181 problems 1, 2; p 186 # 1-2, p 210 #3, 215 #1-2, p 220 #8-12

Friedman-Koffman Review Chapter 5, p 232 # 2-5, p238 # 1-2, p 245 # 1, 2, 4-6, p 265 #1-2, p 268 #1-2, p 273 #2-3, p274 #1, p 284 #1-5, 7-10, p 285 # 6-7 Chapter 6: p 305 #3, p 313 # 1, p 337 #1, 5 Chapter 7 Chapter 8: p 393 #2-3; p 408 # 2-3; p 411 # 2, 4; p 413 # 1-4; p 416 #8-9, review problems 3-5

Chapter 9: p 434 #2-4; p 439 #1-2; p 474 # 4-5 Chapter 10: p 489 #1; p 499 #1; p 535 # 2 Chapter 11.7:p 590 # 2-3