1 Lab Session-XIV CSIT121 Fall 2000 b Tips for good programming b Complete Lab Exercise 13-B for Using Classes b Work on developing an object oriented.

Slides:



Advertisements
Similar presentations
ACM/JETT Workshop - August 4-5, :Design of Classes using CRC cards.
Advertisements

1 Lecture-4 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
Algorithms. Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement.
1 Lab Session-2 CSIT221 Spring 2003 b Intro to Object Oriented Programming b Practice Problem b Lab Exercise (Demo Required)
1 Lab-1 CSIT-121 Spring 2005 Lab Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming Exercise.
1 Lab 2 CSIT-120 Spring 2001 Session II-A (Feb 13th) Operations on Data Lab Exercise 2-A Data Types Variables Lab Exercise 2-B Session II-B (Feb 20th)
1 Lab Session-9 CSIT221 Fall 2002 Lab Exercise Based on operator overloading (Demo Required)
1 Pre-Exam Class CSIT121 Fall 2000 Exam-II (Final Examination) TUESDAY DECEMBER 19th 8:30AM.
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
1 Lab Session-XIII CSIT121 Fall 2000 b Lab Exercise13-A for Handling Files b Lab Exercise 13-B for Using Classes.
Program design example Task: Develop an algorithm expressed in pseudocode for a specified problem specified problem.
Algorithms. Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement.
1 Lab-1 CSIT-121 Fall 2004 Lab Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming Exercise.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
1 Lab 2 CSIT-120 Fall 2000 Session II-A (September 14th) Operations on Data Lab Exercise 2-A Data Types Variables Lab Exercise 2-B Session II-B (September.
1 Lab Session-IX CSIT121 Fall 2000 w Arrays and Their Usage w Examples and Lab Exercises w Passing Arrays to Functions w Examples and Exercises w Sorting.
1 Lab Session-3 CSIT221 Fall 2002 b Exception Handling b Lab Exercise (Demo Required)
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
 To add numbers in scientific notation: 1) Add the constants 2) Keep the exponent the same  Example: (2.1 x 10 5 ) + (3.2 x 10 5 ) = ( ) x 10.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
Lesson 1: Introduction to ABAP OBJECTS Todd A. Boyle, Ph.D. St. Francis Xavier University.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Discussion 5. Lab 3 Not really using rectangle class Return type of getPoint is String instead of Point You are not able to retrieve the point if you.
1 Special Programming Workshop CSIT-120 Fall 2000 Workshop Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming.
Static Methods. 2 Objectives Look at how to build static (class) methods Study use of methods calling, parameters, returning values Contrast reference.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
 A coefficient is the number part of a term that includes a variable.  Example: 2x  2 is the coefficient  x is the variable.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
EXERCISES for ALGORITHMS WRITING
Programming, an introduction to Pascal
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
CSCI-100 Introduction to Computing
1 Program Input Software Design Chapter 4. 2 You Will Want to Know... Prompting for and reading values into a program. Accessing data from a file. What.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Arrays Chapter 13 How to do the following with a one dimensional array: Declare it, use an index.
Program #2 Algorithm for Parking at PSU. Understanding the Assignment You will be writing a program to find out how much someone at PSU might be spending.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Decimal Operations Jeopardy
Homework #2: Functions and Arrays By J. H. Wang Mar. 24, 2014.
Math – The Multiplication/Division Principle of Equality 1.
1 What is a Named Constant? A named constant is a location in memory that we can refer to by an identifier, and in which a data value that cannot be changed.
1 CS 1430: Programming in C++. 2 Input: Input ends with -1 Sentinel-Controlled Loop Input: Input begins with.
Fill In The Blank Multiplying Fractions 1. Fraction Form 2. Multiply Numerators Simplify.
Learning about Inverse Operations. What is the inverse of Opening the door? Turning Right? Driving Forward? The inverse undoes the original function.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Lecture Notes 1/20/05 Pseudocode.  Pseudocode standard which we will follow in this class: - Statements are written in simple English; - Each instruction.
Lives and Scoring Games Programming in Scratch. Games Programming in Scratch L2 Lives and Scoring Learning Objectives Define a variable Understand the.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
Magic 8 ball. "Design and write a python program that emulates a Magic Eight Ball. Your program should continually prompt the user to enter a question.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
Simplify MultiplyDivide Add & Subtract Proportion.
Bill Tucker Austin Community College COSC 1315
Math & Exponents.
Java Programming: From Problem Analysis to Program Design,
Algorithm.
Identifying Parts of an equation
Divide the number in C by 10.
Visit for more Learning Resources
Example Exercise 5 Sales Mix and Break-Even Analysis
Presentation transcript:

1 Lab Session-XIV CSIT121 Fall 2000 b Tips for good programming b Complete Lab Exercise 13-B for Using Classes b Work on developing an object oriented program for implementing a calculator

2 Tips for Good Programming b Always plan for your program on paper before starting on computer b For example, when implementing vending machine object, write down the number of items on sale and the user-interface of the machine

3 Tips for Good Programming b Divide the program into a number of functions, each one dedicated to a small task b In vending machine problem, write a separate function for buying items and another one for displaying remaining items

4 Tips for Good Programming b Before writing a function, write comments about it, including pre and post-conditions and what is it supposed to accomplish. Use meaningful variable names b For example, buy() function allows the user to buy an item. It subtracts one item from the machine’s contents and adds sale amount to total cash in the machine

5 Tips for Good Programming b To represent apple juice cans in the machine, declare a variable called b int apple_juice_cans; b instead of declaring b int var1; b Also constants are to be declared by name b For example, const int price_per_can=50

6 Tips for Good Programming b Use diagnostic messages if your program hangs and you see a blank screen b For example, use b cout<<“OK until this line”<<endl; b and keep moving this statement forward if you see it displayed in the output window

7 Lab Exercise 13-B for Handling Classes b A vending machine contains fruit juices and soft drinks. It can have a maximum of 10 apple juice cans, 10 orange juice cans, 10 mixed juice cans, 10 pepsi cans and 10 sprite cans. Users can buy one can at a time and more items can be added to the machine

8 Lab Exercise 13-B b Develop a program that models this vending machine as an object. It should have all items as private data items and buy/add functions as public functions. There should be another public function show() that shows (prints) all items and their current quantity available.

9 Lab Exercise 14-A b Declare a class calculator that has member functions add,subtract, multiply and divide. It has one private member named result. Only the member functions can access the result. Show implementation of at least two member functions. How will the client program use the result of one function for the other function. For example b (12+3)-5