1 ENGI 2420 Structured Programming (Lab Tutorial 2) Memorial University of Newfoundland.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Computer Programming w/ Eng. Applications
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
1 ENGI 2420 Structured Programming (Lab Tutorial 0) Memorial University of Newfoundland.
Chapter 7: User-Defined Functions II
Introduction to C Programming
What Data Do We Have? Sections 2.2, 2.5 August 29, 2008.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 Wanda M. Kunkle.
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
CS 201 Functions Debzani Deb.
Basic Input/Output and Variables Ethan Cerami New York
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
CSE 1340 Introduction to Computing Concepts Class 2.
Fruitful functions. Return values The built-in functions we have used, such as abs, pow, int, max, and range, have produced results. Calling each of these.
Chapter 3 Getting Started with C++
CH Programming An introduction to programming concepts.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
CS0004: Introduction to Programming Variables – Strings.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Input, Output, and Processing
Jaeki Song ISQS6337 Lecture 01 Introduction. Jaeki Song ISQS6337 Instructor Name: Jaeki Song Office: BA 712 Office Hours Tuesday & Thursday 2:00-3:20.
ECE Application Programming Instructors: Dr. Michael Geiger & Nasibeh Nasiri Fall 2015 Lecture 2: Basic C program structure Data in C: Data types,
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
Fundamental Programming: Fundamental Programming Introduction to C++
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
1 ICS103 Programming in C Lecture 7: Introduction to Functions.
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
1 ENGI 2420 Structured Programming (Lab Tutorial 4) Memorial University of Newfoundland.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Week 6.  Lab 1 and 2 results  Common mistakes in Style  Lab 1 common mistakes in Design  Lab 2 common mistakes in Design  Tips on PE preparation.
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Introduction to Loops Iteration Repetition Counting Loops Also known as.
CSC Programming for Science Lecture 10: Boolean Expressions & More If ­ Else Statements.
1 ENGI 2420 Structured Programming (Lab Tutorial 8) Memorial University of Newfoundland.
9/29/99B-1 CSE / ENGR 142 Programming I Variables, Values, and Types © 1998 UW CSE.
1 ENGI 2420 Structured Programming (Lab Tutorial 5) Memorial University of Newfoundland.
The Hashemite University Computer Engineering Department
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
1 ENGI 2420 Structured Programming (Lab Tutorial 1) Memorial University of Newfoundland.
Dr. Sajib Datta CSE Spring 2016 INTERMEDIATE PROGRAMMING.
1 ENGI 2420 Structured Programming (Lab Tutorial 3) Memorial University of Newfoundland.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
1 2. Program Construction in Java. 01 Java basics.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Bill Tucker Austin Community College COSC 1315
EECE.2160 ECE Application Programming
Topic: Python’s building blocks -> Variables, Values, and Types
EECE.2160 ECE Application Programming
Revision Lecture
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Programming Funamental slides
Introduction to Programming
Functions continued.
Introduction to Programming
FOR statement a compact notation for a WHILE e.g. sumgrades = 0;
EECE.2160 ECE Application Programming
Presentation transcript:

1 ENGI 2420 Structured Programming (Lab Tutorial 2) Memorial University of Newfoundland

ENGI 2420 – Structured Programming Lab Tutorial Problems in the Last Assignment 2.2 Marking Criteria of Programming Style 2.3Some Reminders 2.4Assignment-2 Lab Tutorial 2

ENGI 2420 – Structured Programming Lab Tutorial Problems in the Last Assignment  Always submit the right file (assignN.cpp) to web-submit (around one student per lab section failed in submitting a proper assign1.cpp file)  It is your responsibility to ensure that your assignN.cpp can be correctly compiled with the other downloadable files (available in the assignment requirement on the web) in an Eclipse project 2.1 Problems in the Last Assignment

ENGI 2420 – Structured Programming Lab Tutorial 2 4 Common Problems (I)  Functions in assign1.cpp should exactly follow the declaration given in assign1.h e.g., for “double extraStJohns(int days);”, you should NOT define the following functions in assign1.cpp: double extraStJohns(double days); or double testExtraStJohns(int days);  How to represent a number in C++/C  205, e-3 = 6.67E-3 = 6.67/ Problems in the Last Assignment

ENGI 2420 – Structured Programming Lab Tutorial 2 5 Common Problems (II)  Sometimes space does matter e.g., 6.67e-3  6.67 e-3 data1  data 1  Some conventional expressions may not be valid in C++/C e.g., distance * distance  distance^2  Correct formulas are the most important in computation e.g., return * mpg ; 2.1 Problems in the Last Assignment

ENGI 2420 – Structured Programming Lab Tutorial 2 6 Common Problems (III)  Pay attention to units used in the formulas e.g., return ( e-11 * mass) / (distance * distance );  How to handle double calculation of integer numbers e.g., (days * ) / => integer (days * ) / => double 2.1 Problems in the Last Assignment

ENGI 2420 – Structured Programming Lab Tutorial Marking Criteria of Programming Style  Three main categories: comments, indentation and naming, and simplicity 0, 0.5, or 1 where start with 1 subtract 0.5 for each minor problem subtract 1 for a major problem 2.2 Marking Criteria

ENGI 2420 – Structured Programming Lab Tutorial 2 8 Comments  Major problems include - missing initial file comment blocks - missing all the function comment blocks  Minor problems include - missing key identification information - poor function comments (e.g. omitting units) - necessary in-line comments for key variables or formulas are missing - meaningless comments or overuse of comments 2.2 Marking Criteria

ENGI 2420 – Structured Programming Lab Tutorial 2 9 Two Other Categories  Indentation and Naming - minor problems poor indentation poor choice of names for parameters and functions  Simplicity - major problems include an algorithm that is totally wacky - minor problems use of global variables where local ones would do redundant or useless computations 2.2 Marking Criteria

ENGI 2420 – Structured Programming Lab Tutorial Some Reminders  Unless otherwise indicated, all assignments are due at 11:59 pm the day after the lab for your section  Late assignments will not be accepted except by special permission of the lecturer  Lab Help Centre will be held at 17:00-18:00 on Tuesdays and Wednesdays in Lab 3000/ Some Reminders

ENGI 2420 – Structured Programming Lab Tutorial Assignment-2  Structure of C++ files - a2main.cpp: contains a code that calls the functions using input typed in by the user (Note that you are not expected to understand all of the code in this file at this point in the course) - assign2.h: contains the declarations for the functions - assign2.cpp: contains your implemented functions  Implement two functions as follows 2.4 Assignment-2

ENGI 2420 – Structured Programming Lab Tutorial 2 12 Problem Description The implemented functions work together to compute the rotational velocity of the driven (output) gear (g4) of a gear train. In this system the intermediate gears, g2 and g3, are each made up of two different size gears attached to a single axel so that both parts of each turn at the same rate 2.4 Assignment-2

ENGI 2420 – Structured Programming Lab Tutorial 2 13 Function 1  double rotationalVelocity(double inRotVel, double inTeeth, double outTeeth) - compute the rotational velocity of a driven gear, with outTeeth teeth, given the rotational velocity (inRotVel) and number of teeth (inTeeth) of the gear that is directly driving it (i.e., for a two gear system) - hint: consider direction change for two rotational velocities (using plus/minus sign) 2.4 Assignment-2

ENGI 2420 – Structured Programming Lab Tutorial 2 14 Function 2  double gearTrainOutput(double inRotVel, int g1Teeth, int g2InTeeth, int g2OutTeeth, int g3InTeeth, int g3OutTeeth, int g4Teeth) - compute the output (g4) rotational velocity for the illustrated gear train - for g2 and g3, the InTeeth refers to the number of teeth on the gear that is being driven by the gear to its left, whereas OutTeeth refers to the number of teeth on the gear that is driving the gear on its right - this function must call rotationalVelocity to compute the rotational velocities of the driven gears 2.4 Assignment-2

ENGI 2420 – Structured Programming Lab Tutorial 2 15 Execution Example (I) Available options: 1 - Test rotationalVelocity 2 - Test gearTrainOutput 0 - Quit Please enter a selection: 1 Enter the driving rotational velocity: 10 Enter the number of teeth on the driving gear: 6 Enter the number of teeth on the driven gear: 12 rotationalVelocity(10, 6, 12) = Assignment-2

ENGI 2420 – Structured Programming Lab Tutorial 2 16 Execution Example (II) Available options: 1 - Test rotationalVelocity 2 - Test gearTrainOutput 0 - Quit Please enter a selection: 2 Enter the driving rotational velocity: 10 Enter the number of teeth on the driving gear (g1): 5 Enter the number of teeth on the driven gear of g2: 20 Enter the number of teeth on the driving gear of g2: 5 Enter the number of teeth on the driven gear of g3: 30 Enter the number of teeth on the driving gear of g3: 10 Enter the number of teeth on the driven gear g4: 25 gearTrainOutput( 10, 5, 20, 5, 30, 10, 25) = Assignment-2