IDAHO TRANSPORTATION DEPARTMENT Internship Announcement - PowerPoint PPT Presentation

1 / 54
About This Presentation
Title:

IDAHO TRANSPORTATION DEPARTMENT Internship Announcement

Description:

Miscellaneous work would primarily involve writing code for Access databases for ... strcat( dstr, cstr) puts 'batman in dstr. strcomp - for comparing two string: ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 55
Provided by: teres1
Category:

less

Transcript and Presenter's Notes

Title: IDAHO TRANSPORTATION DEPARTMENT Internship Announcement


1
IDAHO TRANSPORTATION DEPARTMENTInternship
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 ITDs home page.
    Miscellaneous work would primarily involve
    writing code for Access databases for various
    computer programs.

2
IDAHO TRANSPORTATION DEPARTMENTInternship
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
    334-8417 or e-mail bbreen_at_itd.state.id.us

3
IDAHO TRANSPORTATION DEPARTMENTInternship
Announcement
  • HOW TO APPLY Send Resume to
  • Bryon Breen
  • Idaho Transportation Department
  • Maintenance Section
  • 3311 W. State Street P.O. Box 7129
  • Boise, ID 83707-1129
  • APPLICATION DEADLINE Open until filled.

4
Review for final
  • May 15 800-1000 in ET 103
  • comprehensive
  • Open book
  • 2 pages of notes which will be turned in with the
    final

5
Material Covered
  • Hanly Chapters 1-10
  • Friedman-Koffman Chapters 1-5, 6.1-6.2, 7.1-7.4,
    8, 9.1-9.5, 10.1-10.7, 11.7, 13.1

6
Types
int whole number 1
double real or floating point numbers 3.4 1.2e-3
char single character 'a' '\n'
bool logical type true or false
class types built-in and user defined e.g. string
array collection of same type
7
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 3.24159

8
Operators
  • addition
  • - subtraction, negation (unary)
  • multiplication
  • / division
  • integer division discards remainder
  • modulus (int only)

9
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

10
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

11
Precedence
  • parenthesized expressions
  • unary operators - !
  • /
  • - (binary)
  • comparisons lt lt gt gt
  • !

12
math.h
  • Collection of mathematical functions
  • sqrt square root
  • sin, cos, trig functions
  • exp(x) ex
  • log, log10 log functions
  • pow(x, y) power xy
  • abs, fabs absolute value

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

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

15
Boolean Operators
  • comparison operators - boolean result
  • lt lt gt gt !
  • unary
  • ! logical NOT
  • binary operators
  • logical and
  • logical or
  • short circuit evaluation

16
if..else
  • if (condition)
  • thenDoThis
  • else
  • doThat
  • thisAlwaysDone
  • body of if and else one statement unless used

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

18
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

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

20
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

21
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.

22
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.

23
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.

24
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.

25
Arrays
  • a collection of values/objects of the same type
  • they can be of any type
  • int values20
  • sets aside memory for 20 integers
  • The elements are accessed by putting the index of
    the element in square brackets, e.g. values3
  • 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.

26
For arrays, know how to
  • declare an array
  • int score30
  • 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
  • score3
  • first element has index 0

27
Array know how cont.
  • use a loop to do something with every element of
    the array
  • for (int i0 iltnumElements i)
  • sum sum scorei
  • pass the entire array to a function
  • highScore max( score, nstudents)

28
Declaring 2-D arrays
  • similar to one dimensional arrays.
  • int matrix86
  • declares an 8 by 6 array of ints, i.e. an array
    of 8 6-element arrays
  • char wordList1020
  • declares an array of 10 cstrings, each of which
    can have 19 characters

29
String Know-how
C-style ltstring.hgt C string ltstringgt
declare char cstr6 string str
initialize char dstr "cat" char 4 estr"top" string str1"bat" string s2("man")
get length strlen( cstr) s2.length()
get element i cstri s1i s2.at(i)
30
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

31
C string class
  • An object-oriented way to work with text strings
  • include ltstringgt
  • most operators are defined
  • input a string with gtgt output a string with ltlt
  • assign a value using
  • str1 "one"
  • compare using familiar operators
  • str1 str2
  • str2 lt str1
  • concatenate with
  • str1 str2

32
reading with gtgt
  • cin gtgt word gt word Now
  • cin gtgt word gt word is

33
reading with getline
  • getline( cin, line) gt line " the time "
  • getline( cin, line) gt
  • line " for all good men"

34
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

35
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
  • iArrayindex someValue

36
Input and Output
  • include iostream
  • input
  • cin is standard input stream - keyboard
  • gtgt extracts data from input stream and stores in
    variables
  • output
  • cout is standard output stream - monitor screen
  • ltlt inserts data into the output stream

37
File I/O
  • include ltfstream.hgt
  • classes
  • ifstream for input
  • ofstream for output
  • Constructors
  • default
  • initializing takes c-string filename

38
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

39
iomanip
  • setiosflags(iosflagname) resetiosflags(iosflag
    name)
  • right / left
  • fixed
  • scientific
  • showpoint
  • setw( int fieldwidth)
  • setprecision( int digits)

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

41
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 operatorltlt( ostream , const Angle )

42
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

43
Member Function Definitions
  • The function definition contains the code that is
    executed when the function is called.
  • double aClassmemberFunction( 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

44
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.

45
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 lt obj2
  • cout ltlt obj1

46
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

47
Hanly Review Problems
Chapter Pages Exercises
2 45 50 55 60 1, 2 4 1-4 1-2 1-2
48
Hanly Review Problems
Chapter Pages Exercises
3 84 92 94 105 1-4 1-2 1-3 1-5
4 116 125 134 140 1-3 1-5 1, 5 2
49
Hanly Review Problems
Chapter Pages Exercises
3 84 92 94 105 1-4 1-2 1-3 1-5
4 116 125 134 140 1-3 1-5 1, 5 2
50
Hanly
Chapter 5 p 165 p 179 p 185 p 188 1-4 1-2 1-2 1-2
Chapter 6 p 226 p 230 p 239 1, 2 10 2, 4
51
Hanly Review Problems

Chapter 7 p 278 p 289 p 295-297 P 303 2 1-2 1-2 1-2
Chapter 9 p 384 p 387 1 1
52
Friedman-Koffman Review
  • Chapter 2Page 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

53
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

54
  • 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.7p 590 2-3
Write a Comment
User Comments (0)
About PowerShow.com