© 2011 Pearson Education, publishing as Addison-Wesley Tuesday 9-2-14 After answering the questions after logging in, open BlueJ and the Formula class.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Chapter 1: Computer Systems
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Chapter 2 Primitive.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
Outline Java program structure Basic program elements
Chapter 2: Introduction to C++.
Chapter 1 Introduction. © 2004 Pearson Addison-Wesley. All rights reserved1-2 Outline Computer Processing Hardware Components Networks The Java Programming.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.3 The Class String.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 2 Elementary Programming.
Prepared by Uzma Hashmi Instructor Information Uzma Hashmi Office: B# 7/ R# address: Group Addresses Post message:
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
© 2006 Pearson Education Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition.
Primitive Data Types and Operations Identifiers, Variables, and Constants Primitive Data Types Byte, short, int, long, float, double, char, boolean Casting.
Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
Programming Style and Documentation Objective(s) F To become familiar with Java Style and Documentation Guidelines.
1 Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
Java Language and SW Dev’t
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
The Java Programming Language
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Java Syntax and Style JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
Chapter 2: Java Fundamentals
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A programming.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
C++ Basics L KEDIGH. Objectives 1. basic components of a c++ program using proper terminology and programming conventions adopted for this class. 2. List.
Primitive Variables.
C++ Basics L KEDIGH. Objectives 1. basic components of a c++ program using proper terminology and programming conventions adopted for this class. 2. List.
Identifiers.
Documentation and Style. Documentation and Comments  Programs should be self-documenting.  Use meaningful variable names.  Use indentation and white.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
1 Week 5 l Primitive Data types l Assignment l Expressions l Documentation & Style Primitive Types, Assignments, and Expressions.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
The Essentials of a Java Program JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin,
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Working with Java.
مساق: خوارزميات ومبادئ البرمجة الفصل الدراسي الثاني 2016/2015
Variables in C Topics Naming Variables Declaring Variables
Unit-1 Introduction to Java
Chapter 1: Computer Systems
Chapter 2 Variables.
Chapter 2: Java Fundamentals
Variables in C Declaring , Naming, and Using Variables.
Documentation and Style
Anatomy of a Java Program
Chapter 2: Introduction to C++.
Unit 3: Variables in Java
Chap 2. Identifiers, Keywords, and Types
Chapter 2 Primitive Data Types and Operations
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Instructor: Alexander Stoytchev
Introduction to MATLAB
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

© 2011 Pearson Education, publishing as Addison-Wesley Tuesday After answering the questions after logging in, open BlueJ and the Formula class. Check the schedule Identifier Rules and Conventions Constants Static Methods JavaDoc Requirements

© 2011 Pearson Education, publishing as Addison-Wesley 2 Java Program Structure  A Java application always contains a method called main  Our Point and Formula classes do not contain a main method. They are classes but they are not applications.  Our aMain class is an application, it has a main method.  We could put a main method in the Point and Formula Class.

© 2011 Pearson Education, publishing as Addison-Wesley 3 Three Types of Comments // this comment runs to the end of the line /* this comment runs to the terminating symbol, even across line breaks */ /** * this is a javadoc comment * */

© 2011 Pearson Education, publishing as Addison-Wesley 4 What is an identifier?  Identifiers are variables, constants, and methods the programmer creates and uses in a program.  Rules for creating identifiers must be followed or the code will NOT compile.  Conventions are adopted programming practices. The code will still compile if the convention is not followed.

© 2011 Pearson Education, publishing as Addison-Wesley 5 2 Rules for Creating Identifiers  Rule 1 : An identifier can be made up of letters, digits, the underscore character ( _ ), and the dollar sign  Rule 2 : Identifiers cannot begin with a digit  Java is case sensitive - Total, total, and TOTAL are different identifiers  Identifiers should be meaningful, not too short or long.

© 2011 Pearson Education, publishing as Addison-Wesley 6 Conventions – Class Names  The First letter in each word is capitalized. Point Formula Math HelloWorld ArrayList

© 2011 Pearson Education, publishing as Addison-Wesley 7 Conventions – Variable and Method Names  The first word is all lowercase. The first letter of following words are capitalized. name average lastName xCoord getX public double CylinderVolumewithRadiusandHeight (double R, double H) {return Math.PI*(R*R)*H;} public double CubeVolumewithSide (double X) {return X*X*X;}

© 2011 Pearson Education, publishing as Addison-Wesley 8 Conventions – Constants  Constants are special identifiers that can NOT be changed.  Constants are all UPPERCASE. MAX PI  Multiple word constants are separated by an underscore _ TAX_RATE FT_MILE

© 2011 Pearson Education, publishing as Addison-Wesley JavaDoc Requirements  Class JavaDoc Description of the followed by your name without parentheses Larry Kedigh //correct (Larry Kedigh) followed by the date the class was created.  Method JavaDoc Description of the description of the description of what is returned. 9

© 2011 Pearson Education, publishing as Addison-Wesley public double areaHexagon1 (double x) { return *Math.pow(x,2) ; } Example 1 – Constants 10

© 2011 Pearson Education, publishing as Addison-Wesley Example 1 11 public double areaHexagon1 (double x) { return *Math.pow(x,2) ; } Magic Number

© 2011 Pearson Education, publishing as Addison-Wesley public double areaHexagon2 (double x) { final double CON_FACTOR = 3*Math.pow(3,.5)/2; //hexagon formula return CON_FACTOR*Math.pow(x,2) ; }//end aHex Example 1 – Constants 12 public double areaHexagon3 (double x) { // conversion factor in area of hexagon formula // (3 * sqrt(3))/2 return *Math.pow(x,2) ; } //end aHex

© 2011 Pearson Education, publishing as Addison-Wesley /** * Calculates the area of a Hexagon * x Length of a side The area in square units */ public double areaHexagon2 (double x) { final double CON_FACTOR = 3*Math.pow(3,.5)/2;//hexagon formula return CON_FACTOR*Math.pow(x,2) ; } Example 1 – JavaDoc 13

© 2011 Pearson Education, publishing as Addison-Wesley Formula Class Assignment  Edit your Formula class so that The identifier naming convention is followed JavaDoc for each method Magic numbers removed  Link to submission form – will be on the site after class Link to submission form 14 Grading - 80 pts possible The identifier naming convention is followed in all methods(10 pts) JavaDoc for 10 of the 20 method (3 pts/method, 30 total) Magic number / Constants are appropriate in all methods(10 pts) Style and consistency (10 pts) All methods are static (10 pts) Class compiles and works appropriately (10 pts) This due midnight tonight (Tuesday 9-2) One day late -15% or 12 pts. More than one day late - 50% or 40 pts

© 2011 Pearson Education, publishing as Addison-Wesley EXTRAS 15

© 2011 Pearson Education, publishing as Addison-Wesley /** * Calculates the area of a Hexagon x Length of a side The area in square units * info */ public double areaHexagon2 (double x) { final double CON_FACTOR = 3*Math.pow(3,.5)/2;//hexagon formula return CON_FACTOR*Math.pow(x,2) ; } Insert Images and References in JavaDoc 16