What We Will Cover
^ top
1.1: Introduction to Programming Concepts and Methodology, C++
Learner Outcomes
At the end of the lesson the student will be able to:
- Describe what they will learn in this course
|
^ top
1.1.1: Computers in Our Lives
- Computers surround us in our daily lives
- With the Internet, we have access to huge amounts of information
- We use the Internet for many things including: entertainment, education, news, business and socializing
- For instance, you may look at headlines from cnn.com
- Or if you are worried about the guy you met last night, you might visit dontdatehimgirl.com
- Computers let us share photos with our families
- Also, we can get directions to the nearest pizza place for dinner
Solving Problems
- Many real world problems are being solved by computers
- The human genome is analyzed and searched for patterns using computers
- Almost every business uses computers to provide a competitive advantage
- Many late model cars have computers to monitor their status and motion
- The Apple iPod is a computer designed to play music
- You can buy a Roomba vacuum cleaning robot that is controlled by a computer so it can dodge furniture while cleaning your floors
^ top
1.1.2: Computers and Programming
Developing Programs
^ top
1.1.3: Examples of What You Will Learn
- As we learn how to program, we will solve some interesting problems
- Let us take a look at some examples of what you will learn in this course
- First we have some samples from homework assignments:
- postal: Explore how postal bar codes work
- store: Develop our own virtual business
- turtlefun: Draw shapes to produce "artwork"
More Examples
- During the course you will learn how to develop programs like these:
- While these are not assignments this semester, you will be capable of solving these types of programming problems
Student Projects
- Toward the end of the course you will complete a project
- The purpose of the project is to utilize what you learned during the course to produce your own unique program
- In previous semesters students have completed many fascinating projects including:
- 3D shape displays
- Address books
- Ant farm simulation
- Astronomy calculations and simulations
- Bank account programs
- Battleship game
- Database programs (store and retrieve selected data)
- Card games
- Digital photo manipulation (like Photoshop)
- Fortune tellers
- Madlibs game
- Mine sweeper
- Pig Latin translator
- Spectrographic analysis
- You too will be able to create programs like these
^ top
1.1.4: Summary
- We are surrounded by computers in our daily lives
- Computers are used to solve many problems in the real world
- Yet a computer is just a machine that follows a list of instructions
- The list of instructions are called programs
- To develop a program you need the intelligence and creativity of a person
- To solve a problem with a computer, you start with one or more algorithms
- An algorithm is a sequence of precise instructions which leads to a solution
- Once you have an algorithm, you translate an algorithm into a program
- During this semester, we will learn how to computer programs using C++
- We looked at some examples of the programs you could solve after completing this course
^ top
Exercise 1.1: Introductions and Questions
Use the next 10 minutes to complete the following.
- Join a group of 3-4 people and introduce yourself to each other.
- As a group, develop one "burning question" about the course.
- Select one member from your group as a spokesperson to describe your single question to the class.
Note: You do not have to turn in the answers to this exercise. However, you are expected to submit answers to subsequent exercises.
^ top
1.2: Exploring the Course
Learner Outcomes
At the end of the lesson the student will be able to:
- Navigate the course web site
- Discuss how the course is administered
- Know when assignments are due
|
^ top
1.2.1: Some Useful Information and Resources
Email
- All students are requested to have an email account
- Please make sure your email address is correct in WebAdvisor
- When sending me an email please state your name, course number and if you are in the day or evening section
- Please make sure your emails are professional, that words are spelled correctly and that you use good grammar
- If you expect a reply, make certain your spam filter is not removing my emails
- If you have not received my reply within a day, then check your spam folder before sending me another email
Open Lab Hours
^ top
Exercise 1.2: Treasure Hunt
In this exercise we explore the course web site to see how many of our questions we can answer. We will discuss the questions and answers after you have a chance to explore. To find the answers, look at the section we just covered: Some Useful Information and Resources
Specifications
- Work with no more than one other person on this exercise.
- Prepare a text file named:
questions.txt.
- Search the course web site to find answers to the following questions.
- Record the question and its answer in the text file.
- When finished, do not forget to upload your file to Blackboard as part of assignment 1
Exercise Questions
- What is your personal Blackboard login (NOT your password)?
- What do you do if you are late to class?
- Where is the instructor's contact information located?
- What is the closest building next to the instructor's office?
- What is the URL where all lab and programming assignments are listed?
- Where do you turn in homework assignments?
- What course should you take before this one if you are not familiar with computers?
- How much time should you expect to spend on this course outside of the classroom?
- What is CodeLab and why must you spend $25 to purchase it?
- What compiler must you use for this course?
- What is scholastic dishonesty?
- What is an example of acceptable help and an example of unacceptable help on assignments?
- Why is eating and drinking prohibited in the classroom?
- What are three things you should do to succeed in this course?
- In your life, what are three things you choose to do?
- In your life, what are three things you have to do?
^ top
1.2.2: Suggestions for Success in This Course
- You can learn the course material in many different ways
- However, by following the guidelines below you will get a clearer understanding of Internet programming
- Also, you will get the best possible grade
Understanding the Material
- Note the Learner Outcomes for each lesson and concentrate on learning them
- Skim the lecture notes to get an overview of what you need to learn
- Read the assigned pages of the textbook, focusing on the Learner Outcomes
- Note the relationships between the lecture notes and the textbook
- Lecture notes may highlight the text or may present information in a new way
- Attend the lecture, ask questions and participate in the discussions
- After the lecture, review the summary and answer the Check Yourself questions
- This helps to reinforce your learning of the material
- If you cannot answer the questions, then follow up and find the answers
- If you cannot find the answer in the text, then ask a classmate or the instructor
- Suggestion: make a note and ask a question at the start of the next class
The Assignment Cycle
Most assignments (after the first) have three parts:
- Warm Up Exercises:
- The first part is the warm-up exercises, which help prepare you for the problem-solving portion of the assignment
- Warm-up exercises start with exercises we do in class and turn in to Blackboard
- Then you complete several short review exercises, usually in CodeLab
- CodeLab will tell you if you answered correctly and give you some hints if you make a mistake
- Also, after you attempt the problem, you can try again and usually look at the answer in the Solutions tab
- Problem Solving Program:
- The problem solving section lets you explore the concepts in a different way than the exercises
- You will be given a problem and need to develop a solution
- Acceptable solutions must meet a list of specifications
- Tutorial Exercises:
- The tutorial exercises introduce the new material
- First read the assigned reading in the textbook to understand how to solve the problems
- Then complete the tutorial exercises as specified
- Also, you can refer to the online lecture notes as they become available
Preparing for Exams
- Exams provide an opportunity to demonstrate what you have learned
- If you read the textbook, attend lectures, complete the exercises and assignments, and study for each exam, you should do well
- You will need to spend time studying for exams
- I will discuss study techniques before the exams
^ top
1.2.3: Setting Up Your Programming Environment
- Most of your homework assignments will be to solve problems by developing a computer program
- To develop the programs, you will need to use a computer running software programs called software tools
- All the software you need runs on almost any computer
- One of the software tools you need is a compiler
- A compiler is a program that translates C++ (or other programming languages) into the language of the computer
- We will discuss how compilers work next week
- However, the compiler you must use is called
g++ and is free from GCC
- If you use a different compiler, your code may not run when I test it
- If your code does not run you will get a low score
- For Windows, you can install Cygwin, which contains the
g++ compiler
- For Linux/UNIX users, you can install GCC and
g++ compilers from your distribution CD
- If you do not have a computer at home (or work) to use for assignments, then you can use the CTC
- To use the CTC, you will need a login and password
- You are automatically assigned a login and password after you enroll in this course
^ top
1.2.4: Summary
- www.edparrish.com has a link to the course web site and has contact information for the instructor
- Course information describes the course and it grading policies
- Home Page lists the online content of the course
- Schedule lists the planned lesson-topics and assignments
- WebCT/Blackboard is where you turn in assignments, take tests and can look at your grades and get feedback on assignments
- Class Expectations describes what you can expect from me and what I expect from you during the course
- To succeed in this course, you should attend lectures, ask questions and participate in the discussions
- Also, you need to complete your assignments and turn them in before the due date
^ top
1.3: Programming and Problem Solving
Learner Outcomes
At the end of the lesson the student will be able to:
- Describe the activity of programming
- Develop algorithms to solve simple computational problems
|
^ top
Exercise 1.3
- The heart of computer programming is developing algorithms for solving problems using computers
- Algorithm: A sequence of precise instructions which leads to a solution
- In this exercise we explore how to develop an algorithm
- Take about 10 minutes to complete the following specifications
Specifications
- Join a group of 3-4 people for this exercise.
- Prepare a text file named:
walk.txt.
- Analyze the following problem and find an algorithm to solve it.
- Record your algorithm in the text file as a numbered list of steps that will solve the problem.
- Select one member from your group as a representative to describe your answer to the class.
- Do not forget that everyone in your group must upload the text file to Blackboard when finished.
Walking Problem
Develop a precise list of instructions for walking from a spot in front of the instructor's computer to the door of the classroom. You can only use the following commands to describe the algorithm:
- face direction
- forward amount
- backward amount
- turnLeft amount
- turnRight amount
Where:
- direction is a compass heading like north or south
- amount is a number and a unit of measure like feet, paces, degrees or turns
^ top
1.3.1: Computers and Programming
- A computer is a machine that can manipulate data following a list of instructions
- Each of the instructions are extremely primitive
- For example, computers can follow instructions like:
- Get a number from a location in memory
- Get a number from a keyboard
- Add up these two numbers
- If the sum of these two number is positive, put a dot at a specific screen location
- These lists of instructions that computers follow are called programs
- The process of writing programs is called programming
- Computers sometimes appear intelligent because they process huge numbers of these simple instructions
- However, the intelligence you see is from the programmers that developed the list of instructions
Why Develop Programs?
- People develop programs because they want to use a computer to solve a problem
- A computer is well suited to solving a wide range of problems
- Computers can handle repetitive chores without becoming bored or exhausted
- To change what a computer does, you change its list of instructions
^ top
1.3.2: The Activity of Programming
- Programming is about developing a list of instructions for a computer to follow in solving a problem
- The people who develop programs must have expertise in many areas including:
- A problem domain is the body of knowledge for which you are interested in solving problems about
- For example, you may solve problems in domains like:
- Accounting
- Business
- Engineering
- Graphic Design
- As a programmer, you become an expert in the problem domain in which you program
- More information: Why Choose CSE?
Developing Programs
- Computers can only mechanically follow simple and precise instructions
- All the intelligence for a computer program comes from the programmer
- Thus, programming is a creative process
- There is no complete set of rules for creating a program
- However, we know from experience that programs are best developed in two phases
Program Development Phases
- Programs are developed in two general phases:
- Problem-solving phase
- End result is one or more algorithms that solves the problem
- Implementation phase
- End result is the algorithms translated into a programming language
- Each of these phases has several general steps to them

- Problem definition
- First step is to analyze and understand the problem
- We will look at this step in more detail in the next section
- Algorithm design
- Next step is to define an algorithm
- Set of steps that a computer can use to perform a task
- We will look at this step in more detail as well
- Desktop testing
- After developing an algorithm, you need to verify it is correct
- To test, you develop a sample problem
- Walk through each step mentally or manually
- If there is an error, change the algorithm
- Translate to C++
- After you are sure the algorithm works, then write the program code
- Code is written using a programming language
- The language we use for this course is called C++
- As you write the program code, you translate human-readable source code into a language understood by the computer
- You check your translation using a program called a compiler
- Testing
- After code compiles, you test it to make sure it:
- Does what it is supposed to do
- Does not do what it is not supposed to do
- Does what it used to do
- Working program
- When it works well, you document and deliver the program
^ top
1.3.3: Analyzing Problems
- The first step in solving a problem is to understand it
- You need to examine the data and conditions of the problem
- The topics in this section suggest some ways to help you analyze the problem and gain an understanding
Paraphrase the Problem
- A good way to start analyzing a problem is to write it down in your own words
- Often times writing down the problem will lead to other ways of analyzing it
Ask Questions
- If you are given a problem, you naturally ask questions like: What? When? Why? Where? How?
- Here are some questions that are often useful to ask when faced with a programming problem:
- What output is expected?
- What format is required for the output?
- What calculation must be performed?
- What data is needed for the calculations?
- What data do I have to work with?
- Where will I get the data I do not have?
- What do the data items look like?
- How will I know when I have processed all the data?
- How many times is the process going to repeat?
- What special error conditions might happen?
- Start by reviewing this list and answering the questions that seem pertinent
- Ask more questions of your own as your analysis continues
Draw a Diagram
- You have heard the old saying, "a picture is worth a thousand words"
- Sometimes a visualization of the problem can help you understand it
- For example, if the problem is about a rectangle then you draw a rectangle
Look for Similarities
- Often a problem reminds you of other problems you have seen before
- Recognizing similarities can give you insight into understanding the current problem
- For example, if you have seen a problem for a list of numbers then you may see similarities when given a problem dealing with a list of names
Separate the Parts
- If you have a large or complex problem, then you can often break it into smaller pieces that are easier to understand
- For example, if you have to travel from one location to another, you can plan the journey in steps
More Information
^ top
1.3.4: Developing Algorithms
- A computer algorithm is a set of steps that a computer can use to perform a task
- Coming up with a step-by-step method for solving a problem is not always easy
- It is often a trial-and-error process requiring many attempts and refinements
- This is made more complicated because the computer can only do certain things
- Our algorithm must only contain steps that a computer can perform
Operations a Computer Can Perform
- Get data from a keyboard or other input device
- Display data on a screen or other output device
- Move data from one location to another
- Store data into and retrieve data from memory
- Perform arithmetic, such as addition and subtraction, very quickly
- Compare two data values for equality or inequality
- Process instructions in a sequence (in order)
- Process different instructions depending on conditions that are met
- Repeat a set of instructions while certain conditions are met
Devising a Plan
- There are several approaches to solving problems algorithmically
- We will look at several during this course
- One approach you may find useful is: Using a Formula
^ top
1.3.5: Using a Formula
Starting the Analysis
Understanding the Problem
- We continue our analysis by trying to understand the problem in more depth
- We select some of the questions that seem pertinent to the problem
- What output is expected?
- What calculation must be performed?
- What data is needed for the calculations?
- Where will I get the data I do not have?
- What are the answers to these questions for our example problem?
- Thinking about these questions improve our understanding of the problem
- We can see that we can solve the problem by using a formula
Defining the Algorithm
- Once we understand our problem sufficiently, we develop an algorithm
- Remember that we must define our steps using only the operations that a computer can perform
- For our example problem, we might define our algorithm as:
- Get the length of the rectangle
- Get the width of the rectangle
- Calculate the perimeter using the equation:
perimeter = 2 * (length + width)
- Display the result of the calculation
- We must test the algorithm to be certain it is correct
^ top
1.3.6: Summary
- Programming is about solving problems using a computer program
- Programs are best developed in two phases:
- Problem-solving phase
- Implementation phase
- In this section we looked at the first phase: problem solving:
- We will look at the second phase in the next section
- First step to take when solving a problem is to analyze the problem
- Second step is to develop an algorithm that solves the problem
- Only after verifying that the algorithm works do you translate it to C++
^ top
Exercise 1.3b
In this exercise we analyze a problem and develop an algorithm that solves the problem. The algorithm can only use Operations a Computer Can Perform.
Specifications
- Work with no more than one other person on this exercise.
- Prepare a text file named:
algorithm.txt.
- Analyze the following problem and find an algorithm to solve it.
- Record your analysis and algorithm in the text file.
- Do not forget to upload your file to Blackboard when finished.
What is the paycheck amount (before taxes) for an employee who is paid hourly? You may assume that the employee does not get paid extra for overtime.
Check your answer
Check Yourself
Answer these questions to check your understanding. You can find more information by following the links after the question.
- What is a computer? (1.3.1)
- What is a program? (1.3.1)
- What expertise must you develop to write programs well? (1.3.2)
- What are the two main phases of the program design process? (1.3.2)
- What is the output of the problem solving phase? (1.3.2)
- What is the first step to take when developing a program? (1.3.3)
- Why is the problem-solving phase important? (1.3.3)
- What is an algorithm? (1.3.4)
- Why is a formula useful for developing a program? (1.3.5)
^ top
Wrap Up
Due Next: A1-Introductions and Algorithms (2/19/09)
- When class is over, please shut down your computer
- You may complete unfinished exercises at the end of the class or at any time before the next class.
^ top
Home
| Blackboard
| Announcements
| Day Schedule
| Eve Schedule
Course info
| Help
| FAQ's
| HowTo's
| Links
Last Updated: February 24 2009 @22:23:36
|