Course title:Principles of Programming & Problem Solving (10681101)
Instructor: Dr. Emad Saadeh
Contact Information:Email:esaadeh@najah.eduOffice: IT Building, 2nd floor
Course description:
This course introduces the fundamental concepts of programming, problem-solving, and logic thinking. It includes I/O; expressions and arithmetic, if, while and for statements; one-dimensional arrays, string handling, functions, scope, recursion and matrices.
Course Objectives:
The course is a stepping stone, preparing the student to embark on the journey of learning programming in Java and how to solve problems relates to computer. The student will start to learn fundamental programming techniques with primitive data types, variables, constants, assignments, expressions, and operators. Then he will learn how to use control statements, methods, and arrays.
Intended learning Outcomes and Competences:
At the end of this course students should be able to;
- Learn programming principles in general.
- Learn logic thinking.
- Learn basic problem solving skills.
- Understanding some analysis and design concepts.
- Learning structural programming techniques.
- Develop programs that contain sequence, selection and iteration control structures.
Text Book and Online Resources:
Introduction To Java Programming , Ninth Edition, Y. Daniel Liang
Flowchart is a means of visually presenting the flow of data through the java program, the operations performed within the program and the sequence in which they are performed. In this chapter, students will understand the concepts of program flowchart, which describes what operations (and in what sequence) are required to solve a given problem.
Objectives:
After Completing this Section the Student should be able to:
At the end of this lesson, you will be able to understand:
the meaning of flow chart
the basic parts of the flow chart such as flow chart symbols and the flow lines connecting these symbols.
the advantages and limitations of flowchart
Study plan:
First: Students should understand and practice all the flowchart examples given in the class room. Then they have to read the material found in the following links:
In this chapter the students will learn how to create, compile, and run a Java program. They will learn how to solve practical problems programmatically. Through these problems, they will learn elementary programming using primitive data types, variables, constants, operators, expressions, and input/output.
Objectives:
After Completing this chapter the students should be able to:
Write Java programs to perform simple calculations.
Obtain input from the console using the Scanner class.
Use identifiers to name variables, constants, methods and classes.
Program with assignment statements and assignment expressions.
Use constants to store permanent data.
Declare Java primitive data types: byte, short, int, long, float, double, and char.
Use shorthand operators.
Cast the value of one type to another type.
Represent characters using the char type.
Represent a string using the String type.
Obtain input using the JOptionPane input dialog boxes.
Study plan:
First: The students should understand and practice the material and the examples given in the class room. Then they have to read chapter two of text book carefully.
Second: Solve the exercises at the end of chapter two of the text book.
Third: Watch the following videos carefully:
a. Eclipse Java 'Hello World' Introduction Tutorial
b. Java Variables Tutorial
c. Java Syntax and Expressions Tutorial
d. Java Strings Tutorial
e. Java Scanner Tutorial
f. Java JOptionPane: making windows Tutorial
Fourth: Solve the following problems in the lab under the supervision of their lab supervisors:
Lab1: write a java program that print a welcome message on the screen
Lab 2 : write a java program that accept (name and age) from user , and then print their values
Lab 3 : write a java code that calculate the result of this equation and print it (X2 + (25/y)*2). Note : x,y are two variables that must be entered by the users.
In this chapter students will learned how to define boolean types, implement one, two, and nested if statments. Student will learn how to implement selection control using switch statements and how to write expressions using the conditional operator. At the end of the chapter student will learn how to use the confirmation dialogs. Many related programming problems will be discussed through the chapter.
Objectives:
After Completing this Chapter the Student should be able to:
Declare boolean type and write Boolean expressions using comparison operators.
Implement selection control using one-way if statements.
Implement selection control using two-way if statements.
Implement selection control using nested if statements.
Avoid common errors in if statements.
Generate random numbers using the Math.random() method.
Combine conditions using logical operators (&&, ||, and !).
Implement selection control using switch statements.
Write expressions using the conditional operator.
Examine the rules governing operator precedence and associativity.
Use (GUI) To get user confirmation using confirmation dialogs.
Study plan:
First:Students should understand and practice the material and the examples given in the class room. Then read chapter three of the text book carefully.
Second:Solve all the exercises at the end of chapter three of the text book.
Third:Solve the following problems in the lab under the supervision of their lab supervisors:
Lab1:Write a program that generates two integers under 100 and prompts the user to enter the sum of these two integers. The program then reports true if the answer is correct, false otherwise.
Lab2:Write a program that displays a random uppercase letter using the Math.random() method.
Fourth:Solve the following assignments:
Note: Please send your solutions by moodle. for details see Chapter 3 Ass at the end of this section.
a. Write a program that sorts three integers. The integers are entered from the input dialogs and stored in variables num1, num2, and num3, respectively. The program sorts the numbers so that num1 <= num2 <= num3
b. Write a program that prompts the user to enter an integer and checks whether the number is divisible by both 5 and 6, or neither of them, or just one of them. Here are some sample runs for inputs 10, 30, and 23.
10 is divisible by 5 or 6, but not both 30 is divisible by both 5 and 6 23 is not divisible by either 5 or 6
Loops are constructs that control repeated executions of a block of statements. The concept of looping is fundamental to programming. Java provides three types of loop statements: while loops, do-while loops, and for loops. In this chapter students will learned how to use these types of loops. At the end of the chapter student will learn how to use the control an break controls with loops. Many related programming problems will be discussed through the chapter.
Objectives:
After completing this chapter the student should be able to:
To write programs for executing statements repeatedly using a while loop.
To follow the loop design strategy to develop loops.
To control a loop with a sentinel value.
To write loops using do-while statements.
To write loops using for statements.
To discover the similarities and differences of three types of loop statements.
To write nested loops.
To implement program control with break and continue.
Study plan:
First:Students should understand and practice the material and the examples given in the class room. Then they have to read chapter number four from the text book carefully.
Second:Solve all the exercises at the end of chapter four of the text book.
Third:Solve the following problems in the lab under the supervision of their lab supervisors:
Lab1:Write a program that print out all the prime numbers that exist between x and y. The user should enter the values of x and y.
Lab2:Write a program that will calculate the value of z according to the following:
A method is a collection of statements grouped together to perform an operation. In earlier chapters students have used predefined methods such as System.out.println, JOption-Pane.showMessageDialog, Integer.parseInt, Math.pow, and Math.random. These methods are defined in the Java library. In this chapter, students will learn how to define their own methods and apply method abstraction to solve complex problems. Many related programming problems will be discussed through the chapter.
Objectives:
After completing this chapter the student should be able:
To define methods.
To invoke methods with a return value.
To invoke methods without a return value.
To pass arguments by value.
To use method overloading and understand ambiguous overloading.
To determine the scope of variables.
To solve mathematics problems using the methods in the Math class.
Study plan:
First:Students should understand and practice the material and the examples given in the class room. Then they have to read chapter number five from the text book carefully.
Second:Solve all the exercises at the end of chapter five of the text book.
Third:Solve the following problems in the lab under the supervision of their lab supervisors:
Lab:Write a program that read from user a value of integer number x. Then send this number to a method called checkPrime. The method will return true if x is prime and false other wise.
Fourth: Watch the following videos carefully:
a. Methods
b. Use Methods with Parameters
الموضوع 6
Chapter Six:
Introduction:
An array is used to store a collection of data. It is used to define a collection of variables of the same type. Instead of declaring individual variables, such as number0, number1, and number99, the student can declare one array variable such as numbers and use numbers[0], numbers[1], and numbers[99] to represent individual variables. This chapter introduces single-dimensional arrays and show how to declare array variables, create arrays, and process arrays using indexed variables. Many related programming problems will be discussed throughthe chapter.
Objectives:
After completing this chapter the student should be able:
To describe why arrays are necessary in programming.
To declare array reference variables and create arrays.
To initialize the values in an array.
To access array elements using indexed variables.
To program common array operations (displaying arrays, summing all elements, finding min and max elements.
To simplify programming using the for-each loops.
To copy contents from one array to another.
To develop and invoke methods with array arguments and return value.
To define a method with variable-length argument list.
To search elements using the linear or binary search algorithm.
To sort an array using the selection sort.
To sort an array using the insertion sort.
Study plan:
First:Students should understand and practice the material and the examples given in the class room. Then they have to read chapter number six from the text book carefully.
Second:Solve all the exercises at the end of chapter five of the text book.
Third:Solve the following problems in the lab under the supervision of their lab supervisors:
Lab: Write a program that will define two arrays of integer numbers (A and B) of size 10 for each. Fill A of numbers from the user. Then translate to B all the positive numbers found in A.
Fourth:Watch the following videos carefully:
Introduction to Arrays
الموضوع 7
Chapter Seven:
Introduction:
While the preceding chapter introduced how to use one-dimensional arrays to store linear collections of elements, this chapter show how to use a two-dimensional array to store a matrix or a table.
Objectives:
After completing this chapter the student should be able:
To give examples of representing data using two-dimensional arrays.
To declare variables for two-dimensional arrays, create arrays, and access array elements in a two-dimensional array using row and column indexes.
To program common operations for two-dimensional arrays (displaying arrays, summing all elements, finding min and max elements).
To pass two-dimensional arrays to methods.
Study plan:
First:Students should understand and practice the material and the examples given in the class room. Then they have to read chapter number seven from the text book carefully.
Second:Solve all the exercises at the end of chapter seven of the text book.
Third: Solve the following problems in the lab under the supervision of their lab supervisors:
Lab: Write a program that will define 4 X 4 array. Fill it with double numbers. Then find the followings: