Programming Practice (vs Principles)
|
|
- Debra Bryant
- 6 years ago
- Views:
Transcription
1 Programming Practice (vs Principles) Programming in any language involves syntax (with rules, parentheses, etc) as well as format (layout, spacing, style, etc). Syntax is usually very strict, and any small error in spelling or punctuation will prevent a program from running. Format is not as important to the computer, but good spacing and consistent indentation can help humans to read, use and change the code. Java was designed for professional programmers; it was not designed for beginners. JJ is a junior version of Java which was designed for beginners. JJ is a true subset of Java, with a simple environment and many friendly error messages to help beginners. It does not give error messages about things that are not in the subset, so does not confuse beginners. To help beginners JJ has a few rules, which differ slightly from those of Java. If these rules are followed then every program written in JJ will also run on any Java compiler. In fact following these rules will result in better programs in Java. JJ requires that two or more commands not be written on one line. This is just good programming practice in Java anyhow. JJ requires a matching left and right curly brace ( { and } ) even when there is only one line between the braces. So when this occurs in Java, which is rare actually, the brackets may be dropped; but this may cause a dangling else problem which never can occur in JJ. So including these braces is also good programming practice in Java,
2 Beginning One of the first programs in any language is usually to output In Java this First program appears quite complex, as shown below. class First { } public static void main (String[] args) { } System.out.println ( Hello World ); In JJ this entire program can be done as a single line: JJS.outputString ( Hello World ); Hello World. This Java program involves 3 kinds of parenthese, and many advanced concepts such as classes, methods, strings, arrays, and some words (public, static, void, main, System, args, etc) which cannot be understood easily at this early point. JJ introduces the main ideas of Java in gentle stages. Here outputstring is imported from JJS (JJ system) and it prints out the string Hello World which is between the brackets. That s all.
3 A Simple Second Program: with some computation (multiplication) follows; code is at the left; an execution or run is at the right in a dotted box. // Does simple computation with integers JJS.outputString ("10*9*8*7*6*5*4*3*2*1 = "); JJS.outputlnInt ( 10*9*8*7*6*5*4*3*2*1 ); 10*9*8*7*6*5*4*3*2*1 = Comments follow two slashes (//) to the end of the line. They can provide a description (documentation) but are ignored by the computer. Strings are the contents between quotes ( ). The outputstring which is imported from the class JJS (JJ System) prints the string within the quotes exactly. Multiplication is a mathematical operation which is indicated by an asterisk (*). outputlnint, (spoken as output line integer ) is a command or action which evaluates the arithmetic integer expression, prints its value and then outputs a new line. outputint is a similar action; it outputs the expression but does not follow with a new line ( ln), so that any later output occurs on the one same line. Semicolons are required after each command; they are not needed after comments. Case sensitivity refers to upper and lower case letters being different, so outputstring must begin with lower case o and the inner word String must begin with a capital S. Similarly JJS must be all caps; it is not jjs, Jjs, jjs or even J J S.
4 Program Structure Programs consist of 3 parts: Description (or documentation) Declaration (of data and their types) Directives (or commands, instructions) An example of a program in JJ follows in the box below where the three parts are separated by dashed lines. Runs (or executions) of this code are shown in a dotted box. // Name An Omynous // Does compute the circumference given the radius // Shows a typical simple computation with double type public static final double PI = ; // constant double radius; // variable JJS.outputString ("Enter the radius : "); // prompt radius = JJS.inputDouble (); // input JJS.outputlnDouble (radius); // echo JJS.outputString ("The circumference is "); JJS.outputlnDouble ( 2.0 * PI * radius ); Enter the radius : 1.0 The circumference is Enter the radius : 0.0 The circumference is 0.0 Enter the radius : The circumference is
5 Description or documentation is not required, but is nevertheless useful. It consists of a number of comments, beginning with two slashes (//) and continuing to the end of the line. Comments should include who wrote the code, what the code does, and possibly describing why, when, where but not necessariy how, for the code shows how. Declaration of data associates names with boxes of a specified type. Variable declarations consist of lines beginning with a type (int, double, etc) and followed by the names of boxes of that type. Sometimes comments may be used to clarify the names and allow shorter names to be used. Examples of Declarations are: int count; double radius, length, width, height; // size in inches Constants are named in all capitals (with underscores possible) and set to a value in the form: public static final <type> <name> = <value> ; as in the examples: public static final double PI = ; // approximate public static final int YEAR = 2001; // present year public static final String PROMPT = Enter input : ; public static final int FEET_PER_MILE = 5280; Directives or (or actions, instructions) are commands, such as input, output, set (assign) or some constructs (Choice, Loop) or call of some sub-program (method, function, routine). They all end with semi-colons.
6 Convert is a program which converts a real temperature (of type double) from degrees Celsius into degrees Fahrenheit; Some runs are shown at the right. // File Convert.jj // Does Convert temperatures c to f double c; // temperature Celsius double f; // temperature Fahrenheit JJS.outputString ("Enter degrees C : "); c = JJS.inputDouble (); f = 9.0 / 5.0 * c ; JJS.outputString ("Degrees F is: "); JJS.outputDouble ( f ); Enter degrees C: Degrees F is: Enter degrees C: 0.0 Degrees F is: 32.0 Enter degrees C: Degrees F is: Testing, at the right shows some interesting values: that -40 is the same value in Celsius and Fahrenheit. Modify this code to convert from Fahrenheit to Celsius. Test other values (such as 0 degrees f). Does the midpoint 50c map to mid 122f?
7 BirthYear is a program which asks for a person s age, and indicates the year that this person was born; it should be used carefully for older females. // File BirthYear.JJ // Does tell birth year from age public static final int YEAR = 2001; // now int age ; // in years JJS.outputString ("Enter an age : "); age = JJS.inputInt (); JJS.outputString ("You were born around: "); JJS.outputlnInt (YEAR - age); Enter an age : 20 You were born around: 1981 Enter an age : 0 You were born around: 2001 Enter an age : 39 You were born around: 1962 Code a similar program to input the birth year and then output the age.
8 SplitTime converts a given military time into a non-military statement of the time. It uses the integer divide (/) and mod or remainder (%) operations. // Program SplitTime.JJ II // Does split military time // shows use of div (/) and rem (%) int miltime, hour, mins; JJS.outputString ("Enter military time: "); miltime = JJS.inputInt (); // JJS.outputlnInt (miltime); hour = miltime / 100; mins = miltime % 100; JJS.outputString ("It is "); JJS.outputInt (mins); JJS.outputString ( minute(s) \n after "); JJS.outputlnInt (hour); NOTE the \n within the string creates a new line on the output. Enter military time: 1234 It is 34 minute(s) after 12 Enter military time: 2001 It is 1 minute(s) after 20 Enter military time: 9999 It is 99 minute(s) after 99 Enter military time: It is -34 minute(s) after -12 Notice that bad input (such as 9999) gives bad output; Garbage in; Garbage out! Later we will test to verify that the input is proper (hours < 24 and minutes < 60).
9 TimeConvert of minutes into days, hours and minutes is done in two ways as shown. // Does convert minutes to hours, days.. int days, hours, mins; JJS.outputString ("Enter minutes: "); mins = JJS.inputInt (); hours = mins / 60; mins = mins % 60; days = hours / 24; hours = hours % 24; JJS.outputString ("Days = "); JJS.outputlnInt (days); JJS.outputString ("Hours = "); JJS.outputlnInt (hours); JJS.outputString ("Minutes = "); JJS.outputlnInt (mins); Data Flow Diagrams (DFDs) can be very useful here to See the structure. Draw them. days = mins / (24*60); mins = mins % (24*60); hours = mins / 60; mins = mins % 60; Enter minutes: 2000 Day = 1 hours = 9 Minutes = 20 Modify this code to input the number of seconds; test for a million and a billion. Modify this code to output also the number of weeks. Convert similarly cups to gallons, quarts and pints; Do this in 3 different ways.
10 Strings are sequences of characters; they are similar to types, but are objects of a class String. the values of strings are written between a double quote mark. the joining or concatenation of two strings is done by re-using the plus sign (+). // Does format people s names public static final String COMMA = ","; public static final String SPACE = " "; String first, last; // names of people JJS.outputString ("Enter first name : "); first = JJS.inputString (); JJS.outputString ("Enter last name : "); last = JJS.inputString (); JJS.outputString ("The full name is ); JJS.outputString (first + SPACE + last); JJS.outputString ( In directory form "); JJS.outputString (last + COMMA + SPACE + first); Enter first name : Bill Enter last name : Gates The full name is Bill Gates In directory form Gates, Bill Enter first name : Ben Enter last name : Dover The full name is Ben Dover In directory form Dover, Ben Modify this code to include a middle initial of a name, and a constant PERIOD, so that Bill Q. Gates in directory form is output as Gates, Bill Q..
11 MeanSize shows many ways to compute the mean or average number of children per family. It shows a mix of ints and reals, and ways of converting between them. // Does find mean children per family // Shows a mix of int and double types int children, families, intmean, roundmean; double realmean; JJS.outputString ("Enter number of children: "); children = JJS.inputInt (); JJS.outputString ("Enter number of families: "); families = JJS.inputInt (); intmean = children / families; //chops realmean = JJS.intToDouble (children) / JJS.intToDouble (families) ; roundmean = JJS.doubleToInt (realmean ); Enter number of children : 180 Enter number of families : 100 Children per family are : Enter number of children : 100 Enter number of families : 300 Children per family are : JJS.outputString ("Children per family are "); JJS.outputlnInt (intmean); JJS.outputlnDouble(realMean); JJS.outputlnDouble(roundMean);
12 power is a function pow (x,n) which provides the value of x raised to the power y, where both x and y are real (doub le) values. Reliability (probability of success) of a series of n independent parts, each with reliability p, is p to the power of n; or p multiplied by itself n times. Code doing this follows. // Does compute system reliability int num; // number of components double prob; // probability of each JJS.outputString ("Enter number of parts: "); num = JJS.inputInt (); JJS.outputString ("Enter each reliablity "); prob = JJS.inputDouble (); JJS.outputString ( Total reliability is "); JJS.outputDouble (Math.pow (prob, num) ); Enter number of parts : 10 Enter each reliability : 0.9 Total reliability is Enter number of parts : 10 Enter each reliability : 0.99 Total reliability is Other functions that are similarly available from the Math class include: abs(i), abs(d), sqrt(d), rand() as well as others, including trig functions (sin(x), cos(x), tan(x) ).
13 random is a function, imported from the Math class, which provides a real value (type double) between 0.0 and 1.0 which appears to occur by chance. DiceRolls shows how the random function can simulate the roll of one die, which has an integer value from 1 to 6. Then the throw of two such dice is done providing values from 2 to 12. Not all 11 values occur equally often; infact 7 occurs most often and 2 and 12 occur least often. // simulate sum of two dice int first, second, sum; double prob; // 0.0 <= prob < 1.0 prob = Math.random(); first = JJS.doubleToInt (6.0 * prob) + 1; prob = Math.random(); second = JJS.doubleToInt(6.0 * prob) + 1; sum = first + second; JJS.outputString ("Dice sum is "); JJS.outputInt (sum); Dice sum is 12 Dice sum is 11 Dice sum is 6 Dice sum is 5 Dice sum is 7 Dice sum is 2 Dice sum is 8 Dice sum is 7
Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #2
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationJava Programming Fundamentals - Day Instructor: Jason Yoon Website:
Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused
More information7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING
KEY CONCEPTS COMP 10 EXPLORING COMPUTER SCIENCE Lecture 2 Variables, Types, and Programs Problem Definition of task to be performed (by a computer) Algorithm A particular sequence of steps that will solve
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University January 15, 2015 Chapter 2: Data and Expressions CS 121 1 / 1 Chapter 2 Part 1: Data
More information2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program
More informationProgramming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur
Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Lecture 04 Demonstration 1 So, we have learned about how to run Java programs
More informationIntroduction to Java Applications
2 Introduction to Java Applications OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java s primitive types. Basic memory concepts. To use
More informationOverview: Programming Concepts. Programming Concepts. Names, Values, And Variables
Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating
More informationOverview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript
Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating
More informationAP CS Unit 3: Control Structures Notes
AP CS Unit 3: Control Structures Notes The if and if-else Statements. These statements are called control statements because they control whether a particular block of code is executed or not. Some texts
More informationCOMP 202 Java in one week
COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of
More informationVariables and Constants
87 Chapter 5 Variables and Constants 5.1 Storing Information in the Computer 5.2 Declaring Variables 5.3 Inputting Character Strings 5.4 Mistakes in Programs 5.5 Inputting Numbers 5.6 Inputting Real Numbers
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine
More information17 Statement: assignment statement: assigning an expression value 18 Age next year 19 Type: String: conversion: from int 21 Age next year 22 The full
List of Slides 1 Title 2 Chapter 3: Types, variables and expressions 3 Chapter aims 4 Section 2: Example:Age next year 5 Aim 6 Design: hard coding 7 Age next year 8 Type 9 Type: int 10 Variable 11 Variable:
More information12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started
More informationJava Bytecode (binary file)
Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.
More informationPrimitive Data, Variables, and Expressions; Simple Conditional Execution
Unit 2, Part 1 Primitive Data, Variables, and Expressions; Simple Conditional Execution Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Overview of the Programming Process Analysis/Specification
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 2: Data and Expressions CS 121 1 / 53 Chapter 2 Part 1: Data Types
More informationChapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1
Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to
More information3. Simple Types, Variables, and Constants
3. Simple Types, Variables, and Constants This section of the lectures will look at simple containers in which you can storing single values in the programming language C++. You might find it interesting
More informationAP Computer Science Unit 1. Programs
AP Computer Science Unit 1. Programs Open DrJava. Under the File menu click on New Java Class and the window to the right should appear. Fill in the information as shown and click OK. This code is generated
More informationCOSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 123 Computer Creativity Introduction to Java Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) Introduce Java, a general-purpose programming language,
More informationActivity 4: Methods. Content Learning Objectives. Process Skill Goals
Activity 4: Methods Java programs are organized into classes, each of which has one or more methods, each of which has one or more statements. Writing methods allows you to break down a complex program
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationKey Differences Between Python and Java
Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.
More informationCOMP163. Introduction to Computer Programming. Introduction and Overview of the Hardware
COMP163 Introduction to Computer Programming Introduction and Overview of the Hardware Reading Read chapter 1 of the online textbook What is the difference between a simple calculator and a computer? Hardware
More informationCISC 110 Week 3. Expressions, Statements, Programming Style, and Test Review
CISC 110 Week 3 Expressions, Statements, Programming Style, and Test Review Today Review last week Expressions/Statements Programming Style Reading/writing IO Test review! Trace Statements Purpose is to
More informationProgramming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs
Programming Logic and Design Chapter 2 Elements of High-Quality Programs Objectives In this chapter, you will learn about: Declaring and using variables and constants Assigning values to variables [assignment
More informationFunctions. Lab 4. Introduction: A function : is a collection of statements that are grouped together to perform an operation.
Lab 4 Functions Introduction: A function : is a collection of statements that are grouped together to perform an operation. The following is its format: type name ( parameter1, parameter2,...) { statements
More informationProgramming with Java
Programming with Java Variables and Output Statement Lecture 03 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives ü Declare and assign values to variable ü How to use eclipse ü What
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More informationGet JAVA. I will just tell you what I did (on January 10, 2017). I went to:
Get JAVA To compile programs you need the JDK (Java Development Kit). To RUN programs you need the JRE (Java Runtime Environment). This download will get BOTH of them, so that you will be able to both
More informationLesson 6A Loops. By John B. Owen All rights reserved 2011, revised 2014
Lesson 6A Loops By John B. Owen All rights reserved 2011, revised 2014 Topic List Objectives Loop structure 4 parts Three loop styles Example of a while loop Example of a do while loop Comparison while
More informationLesson 2A Data. Data Types, Variables, Constants, Naming Rules, Limits. A Lesson in Java Programming
Lesson 2A Data Data Types, Variables, Constants, Naming Rules, Limits A Lesson in Java Programming Based on the O(N)CS Lesson Series License for use granted by John Owen to the University of Texas at Austin,
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Chapter 2: Data and Expressions CS 121 1 / 51 Chapter 1 Terminology Review
More informationChapter 17. Fundamental Concepts Expressed in JavaScript
Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program
More informationVariables and Typing
Variables and Typing Christopher M. Harden Contents 1 The basic workflow 2 2 Variables 3 2.1 Declaring a variable........................ 3 2.2 Assigning to a variable...................... 4 2.3 Other
More informationSection 2.2 Your First Program in Java: Printing a Line of Text
Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two
More informationA Beginner s Guide to Programming Logic, Introductory. Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs
A Beginner s Guide to Programming Logic, Introductory Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs Objectives In this chapter, you will learn about: Declaring and
More informationClass 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)
Class 2: Variables and Memory Variables A variable is a value that is stored in memory It can be numeric or a character C++ needs to be told what type it is before it can store it in memory It also needs
More informationCS 177 Recitation. Week 1 Intro to Java
CS 177 Recitation Week 1 Intro to Java Questions? Computers Computers can do really complex stuff. How? By manipulating data according to lists of instructions. Fundamentally, this is all that a computer
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More informationInterpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled
Interpreted vs Compiled Python 1 Java Interpreted Easy to run and test Quicker prototyping Program runs slower Compiled Execution time faster Virtual Machine compiled code portable Java Compile > javac
More informationSelec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal
Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program
More informationAdd Subtract Multiply Divide
ARITHMETIC OPERATORS if AND if/else AND while LOOP Order of Operation (Precedence Part 1) Copyright 2014 Dan McElroy Add Subtract Multiply Divide + Add - Subtract * Multiply / Divide = gives the quotient
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More informationCS 112 Introduction to Programming
CS 112 Introduction to Programming Java Primitive Data Types; Arithmetic Expressions Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu
More informationAdmin. CS 112 Introduction to Programming. Recap: Java Static Methods. Recap: Decomposition Example. Recap: Static Method Example
Admin CS 112 Introduction to Programming q Programming assignment 2 to be posted tonight Java Primitive Data Types; Arithmetic Expressions Yang (Richard) Yang Computer Science Department Yale University
More informationChapter 3 Syntax, Errors, and Debugging. Fundamentals of Java
Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different
More informationFaculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions
Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2013 C++ Programming Language Lab # 6 Functions C++ Programming Language Lab # 6 Functions Objective: To be familiar with
More informationCMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD
CMSC 150 INTRODUCTION TO COMPUTING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH INTRODUCTION TO JAVA PROGRAMMING, LIANG (PEARSON 2014) LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationAP Computer Science Unit 1. Writing Programs Using BlueJ
AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationIntroduction to Java Unit 1. Using BlueJ to Write Programs
Introduction to Java Unit 1. Using BlueJ to Write Programs 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationComputer Programming in MATLAB
Computer Programming in MATLAB Prof. Dr. İrfan KAYMAZ Atatürk University Engineering Faculty Department of Mechanical Engineering What is a computer??? Computer is a device that computes, especially a
More informationAdvanced Java Concept Unit 1. Mostly Review
Advanced Java Concept Unit 1. Mostly Review Program 1. Create a class that has only a main method. In the main method create an ArrayList of Integers (remember the import statement). Add 10 random integers
More informationAP Computer Science Unit 1. Writing Programs Using BlueJ
AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationExpressions and Variables
Expressions and Variables Expressions print(expression) An expression is evaluated to give a value. For example: 2 + 9-6 Evaluates to: 5 Data Types Integers 1, 2, 3, 42, 100, -5 Floating points 2.5, 7.0,
More informationIntroduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2
Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2 Ziad Matni Dept. of Computer Science, UCSB Administrative This class is currently FULL and
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationLab # 2. For today s lab:
1 ITI 1120 Lab # 2 Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot 1 For today s lab: Go the course webpage Follow the links to the lab notes for Lab 2. Save all the java programs you
More informationCS 302: Introduction to Programming
CS 302: Introduction to Programming Lectures 2-3 CS302 Summer 2012 1 Review What is a computer? What is a computer program? Why do we have high-level programming languages? How does a high-level program
More informationBB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class:
KS3 Programming Workbook INTRODUCTION TO BB4W BBC BASIC for Windows Name: Class: Resource created by Lin White www.coinlea.co.uk This resource may be photocopied for educational purposes Introducing BBC
More informationArithmetic Expressions in C
Arithmetic Expressions in C Arithmetic Expressions consist of numeric literals, arithmetic operators, and numeric variables. They simplify to a single value, when evaluated. Here is an example of an arithmetic
More informationCOMP 202 Java in one week
CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator COMP 202 Java in one week The Java Programming Language A programming language
More informationSection 2.2 Your First Program in Java: Printing a Line of Text
Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationCSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI
CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are
More informationREVIEW. The C++ Programming Language. CS 151 Review #2
REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,
More informationTOPIC 2 INTRODUCTION TO JAVA AND DR JAVA
1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared
More informationFirst Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
First Programs CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Output System.out.println( ) prints out something. System.out.println is the first
More informationA variable is a name for a location in memory A variable must be declared
Variables A variable is a name for a location in memory A variable must be declared, specifying the variable's name and the type of information that will be held in it data type variable name int total;
More informationCSCE 120: Learning To Code
CSCE 120: Learning To Code Manipulating Data I Introduction This module is designed to get you started working with data by understanding and using variables and data types in JavaScript. It will also
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics 1 Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-3 2.1 Variables and Assignments 2
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style 3 2.1 Variables and Assignments Variables and
More informationChapter 2. C++ Basics
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-2 2.1 Variables and Assignments Variables
More informationFirst Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
First Programs CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Output System.out.println( ) prints out something. System.out.println is the first
More informationCS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 05 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions / Comments? recap and some more details about variables, and if / else statements do lab work
More informationProgramming with Python
Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationWelcome to the Primitives and Expressions Lab!
Welcome to the Primitives and Expressions Lab! Learning Outcomes By the end of this lab: 1. Be able to define chapter 2 terms. 2. Describe declarations, variables, literals and constants for primitive
More informationThe name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.
Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationChapter 3 - Functions
Chapter 3 - Functions 1 Outline 3.1 Introduction 3.2 Program Components in C++ 3.3 Math Library Functions 3.4 Functions 3.5 Function Definitions 3.6 Function Prototypes 3.7 Header Files 3.8 Random Number
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More informationMidterms Save the Dates!
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Primitive Data Types Arithmetic Operators Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch 4.1-4.2.
More informationFirst Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
First Programs CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Output System.out.println( ) prints out something. System.out.println is the first
More informationAN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University
AN OVERVIEW OF C CSE 130: Introduction to Programming in C Stony Brook University WHY C? C is a programming lingua franca Millions of lines of C code exist Many other languages use C-like syntax C is portable
More informationComputer Hardware. Java Software Solutions Lewis & Loftus. Key Hardware Components 12/17/2013
Java Software Solutions Lewis & Loftus Chapter 1 Notes Computer Hardware Key Hardware Components CPU central processing unit Input / Output devices Main memory (RAM) Secondary storage devices: Hard drive
More informationIntroduction to JAVA
Java A001 Hello World Let's study the entire program below: Introduction to JAVA // The "A001" class. import java.awt.*; public class A001 { public static void main (String[] args) { System.out.println("Hello
More informationPython Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018
Python Input, output and variables Lecture 23 COMPSCI111/111G SS 2018 1 Today s lecture What is Python? Displaying text on screen using print() Variables Numbers and basic arithmetic Getting input from
More informationC-1. Overview. CSE 142 Computer Programming I. Review: Computer Organization. Review: Memory. Declaring Variables. Memory example
CSE 142 Computer Programming I Variables Overview Concepts this lecture: Variables Declarations Identifiers and Reserved Words Types Expressions Assignment statement Variable initialization 2000 UW CSE
More informationChapter 2: Programming Concepts
Chapter 2: Programming Concepts Objectives Students should Know the steps required to create programs using a programming language and related terminology. Be familiar with the basic structure of a Java
More informationFull file at C How to Program, 6/e Multiple Choice Test Bank
2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)
More informationJava Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2
Java Foundations Introduction to Program Design and Data Structures 4th Edition Lewis TEST BANK Full download at : https://testbankreal.com/download/java-foundations-introduction-toprogram-design-and-data-structures-4th-edition-lewis-test-bank/
More informationIntroduction to the C++ Programming Language
LESSON SET 2 Introduction to the C++ Programming Language OBJECTIVES FOR STUDENT Lesson 2A: 1. To learn the basic components of a C++ program 2. To gain a basic knowledge of how memory is used in programming
More information