Computer Programming 2 Lecture 2: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

CS110 Programming Language I
Lecture 8. MIPS Instructions #4 – Branch Instructions #2
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
CS0007: Introduction to Computer Programming Methods: Documentation, Reference Parameters, Modularization 2.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Introduction to Computers and Programming Lecture 11: Introduction to Methods Professor: Evan Korth New York University.
Copyright 2010 by Pearson Education Building Java Programs Chapter 7 Lecture 7-1: Arrays reading: 7.1 self-checks: #1-9 videos: Ch. 7 #4.
Math class methods & User defined methods Introduction to Computers and Programming in JAVA: V
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 16: Working with Text.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 6 Introduction to classes and objects.
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 1: Course overview.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Programming 2 Lecture 3: Methods in Advanced & Practices Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER EDUCATION.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 7 Decision Making : selection statements.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Arrays Chapter 8. What if we need to store test scores for all students in our class. We could store each test score as a unique variable: int score1.
Computer Programming 2 Lecture 1: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Programming 2 Lecture 5: String Processing Part b: Class StringTokenizer Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Methods (a.k.a. Functions)
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 5.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Introduction To Programming Information Technology , 1’st Semester
DT249-Information Systems Research Practice Programming Revision Lecture 2 Lecturer: Patrick Browne.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
Procedural Programming Criteria: P2 Task: 1.2 Thomas Jazwinski.
Writing Static Methods Up until now, we have been USING (calling) static methods that other people have written. Now, we will start CREATING our own static.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 9 & 10 Repetition Statements.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 15,16 Java’s Methods.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Programming 2 Lecture 10: File streaming (1) Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington 2D arrays COMP 102 # T1.
Computer Programming 2 Lecture 9: Object Oriented Programming Array Of Objects Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION &
Computer Programming 2 Lecture 8: Object Oriented Programming Creating Classes & Objects Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
Methods.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 18 Recursion & Pointers in Java.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
CSC111 Quick Revision.
Chapter 7 User-Defined Methods.
Presented By: Mahmoud Rafeek Alfarra
CSC305: COMPUTER PROGRAMMING II (JAVA)
Learning about Programming Languages
Presented By: Mahmoud Rafeek Alfarra
TK1114 Computer Programming
Something about Java Introduction to Problem Solving and Programming 1.
Introduction To Programming Information Technology , 1’st Semester
Part a: Fundamentals & Class String
Presented By: Mahmoud Rafeek Alfarra
Introduction To Programming Information Technology , 1’st Semester
Introduction To Programming Information Technology , 1’st Semester
Presented By: Mahmoud Rafeek Alfarra
Week 4 Lecture-2 Chapter 6 (Methods).
Presented By: Mahmoud Rafeek Alfarra
Introduction To Programming Information Technology , 1’st Semester
Methods/Functions.
Presented By: Mahmoud Rafeek Alfarra
Computer Science Club 1st November 2019.
Presentation transcript:

Computer Programming 2 Lecture 2: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY (CST) KHANYOUNIS- PALESTINE

و من يتقِ الله... ذكر معروف الكرخي عن بكر بن خنيس رحمهما الله قال : كيف يكون مُتَّقِيًا مَنْ لا يَدْرِي مَا يَتَّقِي Mahmoud Rafeek Alfarra 2 Downloaded from شريحـة ثابتـة لعلنا نحسن من خلالها أخلاقنـا و أفعالنا لنفوز يوم الامتحان الحقيقي

Out Lines Mahmoud Rafeek Alfarra Downloaded from Downloaded from 3 Revision about Methods in Java Example: Search in 2-D Array X O Project.

Revision about Methods in Java Mahmoud Rafeek Alfarra Downloaded from Downloaded from 4 Three kinds of modules exist in Java methods, classes and packages. Methods (called functions or procedures in other programming languages) allow the programmer to modularize a program by separating its tasks into self-contained units.

Revision about Methods in Java Mahmoud Rafeek Alfarra Downloaded from Downloaded from 5 To Create Method: Access modifiers returned_type Method_name (Type par1, Type par2, … ) control access to a class's variables and methods. The value which the method will returned The name of method with the rules of identifiers The arguments which the method needs to perform its task

Example : Method accepts and return Mahmoud Rafeek Alfarra Downloaded from Downloaded from 6 Method return true if the parameter x is available in in array Names else return false. Method Array wanted True/false

Mahmoud Rafeek Alfarra Downloaded from Downloaded from 7 import javax.swing.JOptionPane; import java.math.*; public class Searchnumbers { public static void main(String[] args) { String input; int num [] = new int [10]; boolean flag= false; for (int i=0; i<5; i++) { input = JOptionPane.showInputDialog("Enter another number"); num[i]= Integer.parseInt(input);} input = JOptionPane.showInputDialog("Enter the wanted value"); int wanted = Integer.parseInt(input); int j; for ( j=0; j<5; j++) { if (num[j]==wanted) { flag = true; break; } } if (flag == true) JOptionPane.showMessageDialog(null,"the value is existed at cell "+j); else JOptionPane.showMessageDialog(null,"the value does not exist"); } Solution without using Methods

Example : Method accepts and return Mahmoud Rafeek Alfarra Downloaded from Downloaded from 8 In the last example: 1. Set the type of array as string 2. Re-programming it using Methods

Practice Mahmoud Rafeek Alfarra Downloaded from Downloaded from 9 Write a program to simulate the Attendance status for 10 students’ names (fname, laname), in 5 days for each student. Write a program to simulate the Attendance status for 10 students’ names (fname, laname), in 5 days for each student. Write a methods to: Write a methods to: 1. Calculate the sum of absent for each student. 2. Return the name of student who have the max number of absent days. 3. If the attendance of one day have 2 marks, print the marks for each student.

X O Project Mahmoud Rafeek Alfarra Downloaded from Downloaded from 10 Using Procedural programming, 2-d array, Write a program to simulate the XO game between user and computer.

Next Lecture … Mahmoud Rafeek Alfarra Downloaded from Downloaded from 11 Method in depth