Introduction to mcp
This presentation is the property of its rightful owner.
Sponsored Links
1 / 15

Introduction to MCP PowerPoint PPT Presentation


  • 55 Views
  • Uploaded on
  • Presentation posted in: General

Introduction to MCP. CPS 1 Summer 2002 Shannon Pollard. Algorithms. Algorithm: A detailed set of instructions for solving a problem that: Has a finite number of steps Takes a finite amount of time. Multiple-Choice Programming. Way to write out algorithms

Download Presentation

Introduction to MCP

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Introduction to mcp

Introduction to MCP

CPS 1

Summer 2002

Shannon Pollard


Algorithms

Algorithms

  • Algorithm: A detailed set of instructions for solving a problem that:

    • Has a finite number of steps

    • Takes a finite amount of time


Multiple choice programming

Multiple-Choice Programming

  • Way to write out algorithms

  • Show the level of detail you need to use

  • Some things provided for you

  • Not learning Java

  • Focus on universal aspects of programming


Lessons learned from pb j variables

Lessons Learned from PB&J:Variables

  • Need a way to name things (bread slice 1)

  • Variables: Names assigned to things so they can be referred to later.

    int x = 4;

  • Remember Algebra? Kind of, but not quite…Thing on left gets CHANGED!!

    int y,z;y = 4; (“Y gets 4”)z = y;y = 6;z = z+1;


Variables cont d

Variables, Cont’d

  • Variables have Type- what kind of thing is it?

  • int, double

  • boolean – things that are either true or false

  • Strings – “Put anything in quotes!”

  • Objects – Anything!!!

  • You first must tell the type of a variable, then you can give it a value

  • Examples: int x = 4;String answer = “Here it is!”;boolean b = (x==3);


Lessons learned from pb j subroutines

Lessons Learned from PB&J:Subroutines

  • Allow a set of steps to be done over again with little change, without rewriting everything (Now repeat steps 3-15 with bread slice 2 and jelly)

  • Subroutines may or may not take input (parameters) or give an answer (return something).

  • Examples:int y = addTwo(42);String s = whatsMyLine();quit();


Subroutine specifics

Subroutine Specifics

  • Header – information at beginning of subroutine, including its name

  • Header has type of thing returned, or void keyword

  • Parameters – tell type of inputs and gives them local names

  • Must have return statement unless return type void

  • Can be used by name by other functions


Lessons learned from pb j loops

Lessons Learned from PB&J:Loops

  • Loops are used to do a sequence of steps some number of times, or only in certain situations (Repeat steps 3-10 5 times; Repeat step 4 until the jelly is spread, do step 5 only if there is more bread.)

  • Need to use booleans – things that are either true or false(x<=5)myString.equals(“Shannon)(obj!=null)


Loops contd

Loops, Contd

  • If Statements

    if (BOOLEAN)

    {

    STATEMENTS

    }

    else

    {

    STATEMENTS

    }


If example

If Example

int x = 4;

x = x + 14;

if (x < 18)

{

x = 0;

}

else

{

x = 1;

}

return x;


Loops cont d

Loops, Cont’d

  • While Loops

    while(BOOLEAN)

    {

    STATEMENTS

    }


While loops

While Loops

int x = 4;Initialization

while (x < 10)Check

{

x = x+1;Update

}

return x;


Introduction to mcp

int x,y;x = 100;y = addThree(x);

public int addThree(int number)

{

return number + 3;

}

public void writeOut(String line)

{

System.out.println(line);

}

String myName;myName = “Shannon”;writeOut(myName);


Introduction to mcp

public List listCPS1(List master) { List answer = new List(); List cps1 = getClassList(cps1); int last = master.length(); int index = 1; while (index <= last) { Student s = master.getMember(index); if (cps1.contains(s)) { answer.add(s); } index = index + 1; } return answer;}


Mcp format

MCP Format

  • Most lines specified that you need to write

  • You must fill in the correct variables or statements

  • You make your own variables as needed

  • Things in CAPS are supposed to be substituted!!

  • Other things must be typed exactly

  • Order matters!

  • Cheat Sheet provided


  • Login