Object-Oriented COBOL?
Abstract
Surely the title of this presentation is given in jest. We all realize that COBOL cannot
possibly be considered Object-Orientedor can it? Even though we all perceive COBOL as
a language written in ancient times by ancient p
Page
I. OVERVIEW: Chapter 1
Introduction
This chapter provides an introduction to computer science and a brief background on
programming languages. The concepts of objects and classes are explained and a specific
structure that will be used throughout the
Controlling Execution
Gaddis, Chapter 4
1
Making decisions
Until now, we executed our programs by processing instructions sequentially. This is the
default way of executing most procedural languages.
An if statement allows a program to branch, meaning t
/ Chapter 5, Programming Challenge 8: Math Tutor
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
cfw_
int num1, / The first random number
num2, / The second random number
choice, / The user's c
/ Chapter 4, Programming Challenge 11: Math Tutor
#include <iostream>
#include <cstdlib> / For rand and srand
#include <ctime> / For the time function
#include <iomanip>
using namespace std;
int main()
cfw_
/ Constants
const int MIN = 50;
const int MAX
/ Chapter 3, Programming Challenge 17: Math Tutor
#include <iostream>
#include <cstdlib> / For rand and srand
#include <ctime> / For the time function
#include <iomanip>
using namespace std;
int main()
cfw_
/ Constants
const int MIN = 50;
const int MAX
#include <iostream>
using namespace std;
void greetUser()
cfw_
cout < "Lets Have some Fun!";
int main()
cfw_
double C = 0 ;
double T = 0 ;
double P = 0 ;
cout < "Welcome to inflation calculator"< endl;
greetingUser();
cout< "Enter the current price of it
CIS3100 Fall 2016.
Midterm #1 Short Questions
Midterm Review Part I
1. How would you assign a value of 1 to x? x = 1;
2. Suppose x is 1. What is x after x -= 1? 0
3. Suppose x=10 and y=10 what is x after evaluating the expression (y >=
10) | (x+ > 10). 11
CIS3100 Fall 2016.
Midterm #1 Code Output
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
int main()
cfw_
cout < "A";
cout < "B";
cout < "A";
int j = 1;
int main()
cfw_
int i = 2;
cout < "i is " < i < " j is " < j < endl;
CIS3100 Fall 2016.
Midterm #1 Write Code
Review for Midterm - Write Code Questions
Write a program that calculates the highest score for the 3 students in the
class. The user enters each students score, and then finally displays the
highest score.
<Output
CIS3100 Fall 2016.
Midterm #1 Short Questions
Midterm Review Part I
1.
2.
3.
4.
5.
6.
7.
8.
How would you assign a value of 1 to x?
Suppose x is 1. What is x after x -= 1?
Suppose x=10 and y=10 what is x after evaluating the expression
(y >= 10) | (x+ > 1
CIS3100 Fall 2016.
Midterm #1 Types of Questions
1. What is wrong with this code? (underline the errors, and rewrite it correctly)
int i, j = 4, k;
for (int i = 0, i < 10, i+)
if i < j & j > k
cfw_
cout < The value of i is < i < ;
2. What is the output o
/ This program displays a menu and asks the user to make a
/ selection. A do-while loop repeats the program until the
/ user selects item 4 from the menu.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
cfw_
/ Constants for menu cho
Lecture 1 Introduction
to Computers and
Programming
Gaddis, Chapter 1 and 2
1
Definition of Computer
A COMPUTER is an electronic device that can:
Receive information
Perform processes
Produce output
Store info for future use
In other words, the inform
CIS 3100
Quiz 1B
Feb. 24, 2016
Name _
I.
Evaluate the following expressions (12 pts.)
int a=4, b=10, c =12;
int result;
float answer;
result = a + b/c;
result = c % b;
answer = c / a;
II.
result=4 + 10/12 = 4 + 0 = 4
result= 12 % 10 = 2
answer=12/4 = 3, s
Lecture 4 Loops and
I/O
Gaddis, Chapter 5
1
Iteration
Until now, we have not been able to do iterative or repeat processing.
Suppose we are asked to print the numbers from 1 to 5.
We can do that in this way:
int num=1;
cout <num<endl;
num+;
/num=2 now
CIS 3100
Quiz 1A
Feb. 24, 2016
Name _
I.
Find and correct the errors. There may be more than one error in each problem.
Assume that all the correct libraries have been included (40 pts.)
1. int x=4,y=3;
x = 2(x + y);
cout<x<end;
a. x = 2*(x+y);
b. cout<x<
Program Design
1
Introduction
Designing a program is a creative process. It is best to perform it in 2 stages:
problem-solving phase
Implementation phase
Problem- solving involves making sure that you understand the problem,
then producing an algorith
Arrays
Gaddis, Chapter 7
1
Introduction
Suppose a Weight watchers site is keeping track of the weights of a group of
people. They want to find the average weight in the group and the lowest weight.
They would also like to list all the weights that are wi
Lecture 1A Mathematical
Expressions and Formatting
Output
Gaddis, Chapter 3
Arithmetic Operators in C+
Addition a+b
Subtraction a-b
Multiplication a*b
Division a/b
Modulus a' the remainder when you divide a by b (only
defined for integers)
\
2
Examples
Ex
Functions
Gaddis, Chapter 6
1
Introduction
Def.: A function is a series of instructions that perform a specific task.
All C+ programs are composed of functions.
A function can be written as a separate module and given a name.
Then the function can be
String Practice Problems Solution
Problem 1:
The following program is supposed to get an input phrase from the user and replace every other
character with an asterisk *, starting with the second letter.
So the phrase "LORD OF THE RINGS" becomes "L*R* *F*T
Spring 2015.
HW #4. Chapters 5.
1. Read chapters 5.
2. Algorithm workbench only pseudo-code. (chapter 5, question 36)
3. Find the errors (chapter 5, question 68)
/ This program averages a set of numbers.
#include <iostream>
#include <iomanip>
using namesp
6/27/2014
*
The Increment and Decrement
Operators
+ is the increment operator.
It adds one to a variable.
val+; is the same as val = val + 1;
+ can be used before (prefix) or after (postfix) a
variable:
+val;
val+;
The Increment and Decrement
Operators
#include <iostream>
using namespace std;
int main()
cfw_
/ WHILE
cout < "WHILE \n";
cout < "- \n";
int count = 0;
while (count < 2)
cfw_
cout < "Welcome to C+!";
cout < endl;
count+;
/ DO WHILE
cout < "DO WHILE \n";
cout < "- \n";
int counter = 0;
do cfw
CIS3100 Fall 2016.
Midterm #1 Types of Questions
1. What is wrong with this code? (underline the errors, and rewrite it
correctly)
int i, j = 4, k;
for (int i = 0, i < 10, i+)
if i < j & j > k
cfw_
cout < The value of i is < i < ;
2. What is the output o
CIS3100 Fall 2016.
Midterm #1 Basic Outline
Themes for Midterm
1. Basic Input/output
2. Conditional Logic
a. If
b. If-Else
c. Case/Switch Statements
d. Comparison Operators
i. <
Less than
ii. <=
Less than or Equal to
iii. >
Greater than
iv. >=
Greater tha
CIS3100 Fall 2016.
Midterm #1 Other Concepts
Pre-Processor Directives/Libraries.
#include <iostream>
#include <iomanic>
#include <string>
#include <cmath>
Conditional Logic Concepts.
If/else
Case
Loops.
While
Do-While
For
Order of Precedence & Associativi
Concordia University
Comp 218/All sections Fall 2005
Fundamentals of Object Oriented Programming
Assignment 5 - Due week #13
_
PURPOSE: This assignment will give you the opportunity to write the declaration for a structure and
use it, to define and use a
CIS3100
Lab Assignment 8
Programming with C+
Name:
I.
I.
Write the output of the following segments of code and trace it.
a.) string a = "LOTR";
a.insert( 1, a.substr(0,2) );
cout < a;
b.) double b = 5;
cout < b/2 < (int) b%2;
c.) int c = 1;
while (c < 20