Professional Documents
Culture Documents
To Computing and Engineering Problem Solving
To Computing and Engineering Problem Solving
To Computing and Engineering Problem Solving
Chapter 1
INTRODUCTION
TO COMPUTING
AND ENGINEERING
PROBLEM SOLVING
Outline
1. Objectives
2. Computing Systems
3. An Engineering Problem-Solving
Methodology
Objectives
Introduce computing and engineering
problem solving, including:
A discussion of hardware and software
A five-step problem-solving methodology?
Copyright 2012 Pearson Education, Inc.
Computing Systems
A computing system is a complete working
system that includes:
Hardware(h\w)
Software (s\w)
Copyright 2012 Pearson Education, Inc.
Hardware
Hardware(h\w) (i.e. they can actually be
touched):
Physical parts of the computing system
that have mass
Computer
Display
Mouse
Printer
Hardware
Jon von Neumann computing model
1.
2.
3.
4.
Input device(s)
Output device(s)
Memory Unit
CPU (Central Processing
Unit) consisting of:
C
P
U
Control Unit
ALU (Arithmetic Logic Unit)
Hardware
Jon von Neumann computing model
1. Input device(s)
2. Output device(s)
Hardware
Jon von Neumann computing model
3. Memory Unit
Stores data
4. CPU(Central Processing Unit)
Controls the transfer and the process of the
data
Control Unit
ALU (Arithmetic Logic Unit)
Copyright 2012 Pearson Education, Inc.
Software
Computer software refers to programs
that reside and execute electronically
on the hardware.
Operating systems: e.g. Windows, Unix, Linux,..
Provide the HCI (Human Computer Interface)
Application programs
Provide problem solutions e.g. M.S. Word, Excel,
Matlab
Computer Languages
Computer Languages: three levels
Machine Language: written using the digits 0s and 1s
(binary).
Assembly Language: written in symbolic statements
High-Level Language: C++, Java, Basic, (Englishlike commands.)
Copyright 2012 Pearson Education, Inc.
10
Computer Languages
11
Software Interface to
Computer Hardware
12
Building a Program
Computers only understand machine
language. High-level languages like C++
must be translated to machine language
for execution.
13
Building a Program
program written in a high-level language such as C++
must be translated into machine language
Compiler
Converts source program to object program
Linker
Converts object program to executable program
14
Key Terms
Source Program
printable/Readable Program file
Object Program
nonprintable machine readable file
Executable Program
nonprintable executable code
Copyright 2012 Pearson Education, Inc.
15
Errors in Programs
Syntax/Parse Errors
Mistakes with the language.
Always reported by the compiler
Linking Errors
Missing pieces prevent the final assembly of an
executable program.
Run-time Errors
Occur when program is executing.
May or may not be reported.
Copyright 2012 Pearson Education, Inc.
16
Logic Errors
Can be difficult to find.
Debugging can be time consuming.
Better tools for find bugs
17
Debugging
Process of eliminating logic errors
(i.e. bugs) from programs.
User-friendly programming environments
such as Microsoft Visual C++ integrate the
compiler with
18
Engineering
Problem-Solving
Methodology
19
Five Step
Problem-Solving Methodology
1. State the problem clearly.
2. Describe the input and output information.
3. Work the problem by hand, give example.
4. Develop a solution (Algorithm development) and
convert it to a computer program (C++ program).
5. Test your solution with a variety of data.
20
Example 1
Write a computer program to calculate the
volume of a box based on its length, width
and height. The program should allow the
user to enter the length, width and height
of the box and it should calculate the
corresponding volume and display the
result.
21
Example 1
1. Problem Statement: Write a program to compute the volume of box.
2. Input: length, width, height
Output: volume
3. Hand Example:
volume = 20.75*11.5*9.5
9.5
20.75
11.5
4. Algorithm:
1- input length, width and height
2- compute volume
3- output volume
and Implement algorithm in C++ (See next slide)
5 test.
22
/************************************************************/
/* Example 1
/* This program computes the volume of a box
/************************************************************/
#include <iostream>
using namespace std;
*/
*/
int main()
{
// Declare and initialize objects
double length;
double width;
double height;
double volume;
// get the user input
cout << Enter the length of the box: ;
cin >> length;
cout << Enter the width of the box: ;
cin >> width;
cout << Enter the height of the box: ;
cin >> height;
// Calculate volume.
volume = length * width * height;
// Print the volume.
cout << The volume is << volume << endl;
// Exit program.
return 0;
23
Example 2
(x1,y1
)
1.Problem statement
(x2,
y2)
2.Input/output description
Point 1 (x1, y1)
Point 2 (x2,
y2)
24
Example 2
(contd)
3. Hand example
distance side12 side2 2
side1 = 4 - 1 = 3
side2 = 7 - 5 = 2
distance side12 side2 2
distance 3 2
2
distance 13 3.61
25
Example 2 (contd)
4. Algorithm development and coding
a)
b)
side12 side2 2
5. Testing
26
2. I/O
3. Hand example
area = * 3 *4 = 6 cm2
x
y
y=4 cm
area
5. Testing
1.
2.
3.
Print area
27
a1
b1
a2
b2
2. I/O
3. Hand example
a3
b3
5. Testing
1.
Get a1 b1 a2 b2
2.
Compute a3 = a1 + a2
3.
Compute b3 = b1 + b2
4.
Print z3 = a3 + b3 * i
28
total_sec
2. I/O
3. Hand example
4. Develop solution
and Coding
5. Testing
H
M
S
Get total_sec
2.
3.
M = (total_sec (H*3600)) / 60
M = (total_sec mod 3600) / 60
4.
5.
29