Programming Process - Concordia University Wisconsin

Download Report

Transcript Programming Process - Concordia University Wisconsin

Programming Process

Written Assignment 2 modified problem 31, page 369 (end of chapter 7 in ICS) CSC 175 - Dr. Gary Locklair

Programming Process

Written Assignment 2 hint: build program in “stages” CSC 175 - Dr. Gary Locklair

Programming Process

Written Assignment 2 create codewarrior project file on your Chemnitz student data folder under a folder called CSC175 under a folder called assn2 CSC 175 - Dr. Gary Locklair

Programming Process

A review of programming and the C++ language (from CSC 150) Chapter 7 in ICS CSC 175 - Dr. Gary Locklair

Programming Process

Programming Language A PL (Programming Language) is a collection of possible instructions for the CPU (control unit) CSC 175 - Dr. Gary Locklair

Programming Process

Purpose - allow a programmer to create application packages; CSC 175 - Dr. Gary Locklair

Programming Language

CSC 175 - Dr. Gary Locklair

Programming Language

CSC 175 - Dr. Gary Locklair

Programming

Users do not program VCRs – why not? Which level of problem solving?

CSC 175 - Dr. Gary Locklair

Programming Language

Mechanic / Tool Kit Programmer / PL CSC 175 - Dr. Gary Locklair

The C++ “Tool Kit”

break do for switch cin else if while cout float int ...

CSC 175 - Dr. Gary Locklair

Programming Language

CSC 175 - Dr. Gary Locklair

Programming Language

Variables fields which “hold” data symbolic representations of data rules in C++ name, type, etc CSC 175 - Dr. Gary Locklair

Programming Language

Variable contents 35 type integer name length CSC 175 - Dr. Gary Locklair

Programming Language

Statements instructions for the CPU syntax semantics CSC 175 - Dr. Gary Locklair

Programming Language

Comment Statement: // program purpose ignored by CPU explain why, not what CSC 175 - Dr. Gary Locklair

Programming Language

Input Statement: cin >> length; allows user to input data value is assigned to variable CSC 175 - Dr. Gary Locklair

Programming Language

Assignment Statement: area = length * width; assigns a new value to a variable evaluate r.h.s. and assign to l.h.s.

CSC 175 - Dr. Gary Locklair

Programming Language

Output Statement: cout << “The area is " << area; display information on the monitor CSC 175 - Dr. Gary Locklair

Programming Language

{ // implementation cout << “what is the length of room?”; cin >> length_ft; cout << “what is the width of room?”; cin >> width_ft; area = length_ft * width_ft; … } CSC 175 - Dr. Gary Locklair

Read a program

ICS text page … 301, figure 7.4

322 “kms conversion” CSC 175 - Dr. Gary Locklair

declare variables

const double M_T_K = 1.6; const double K_T_M = 0.6; double Miles; double Kms; int Task; CSC 175 - Dr. Gary Locklair

input data

cout << “M to K (enter 1)” << endl; cout << “K to M (enter 2)” << endl; cin >> Task; cout << endl; CSC 175 - Dr. Gary Locklair

selection if structure

{ { if (Task == 1) yes (true) } else no (false) } CSC 175 - Dr. Gary Locklair

if (Task == 1) yes (true)

cout << “Miles” << endl; cin >> Miles; Kms = M_T_K * Miles; cout << “It is” << Kms << “kilometers” << endl; CSC 175 - Dr. Gary Locklair

if (Task == 1) no (false)

cout << “Kms” << endl; cin >> Kms; Miles = K_T_M * Lms; cout << “It is” << Miles << “miles” << endl; CSC 175 - Dr. Gary Locklair

Read a program

ICS text page … 325 “loop to add numbers” CSC 175 - Dr. Gary Locklair

Lab

The CodeWarrior IDE CSC 175 - Dr. Gary Locklair

Programming Environment

The CodeWarrior IDE CSC 175 - Dr. Gary Locklair

Programming Environment

The CodeWarrior IDE CSC 175 - Dr. Gary Locklair

Programming Environment

The CodeWarrior IDE CSC 175 - Dr. Gary Locklair