Docsity

JAVA PROGRAMMING WITH OOP, Slides of Computer Science

Partial preview of the text

Download JAVA PROGRAMMING WITH OOP and more Slides Computer Science in PDF only on Docsity!

Introduction Problem solving is a process of transforming the description of a problem into the solution of that problem by using our knowledge of the problem domain and by relying on our ability to select and use appropriate problem-solving Strategies, Techniques and Tools.

Problem Definition The computer is the symbol-manipulating machine that follows the set of instructions called a program. A problem is a task to be performed. It is best thought of in terms of inputs and matching outputs. A problem definition should not include any constraints on how the problem is to be solved. Any computing has to be performed independently without depending on the programming language and the computer.

Problem Solving Techniques The problem solving techniques involves the following steps:  Define the problem  Formulate the mathematical model  Develop the algorithm  Write the code for the problem  Test the program

Problem Solving Techniques Any technical problem provided can be solved mathematically. Full knowledge about the problem should be provided along with the underlying mathematical concept. Example: Data 1 + Data 2 / 2 (Data 1 + Data 2 ) / 2 Formulate Mathematical Problem

Problem Solving Techniques ā€œA step by step process is known as the algorithm.ā€ An algorithm is any well-defined computational procedure that takes a value or set of values as input and produce an output. The algorithm is very important for programmers. Algorithm

Algorithm Algorithm for adding two numbers Step – 1 - START Step – 2 - Input A and B Step – 3 - C = 0 Step – 4 - C = A + B Step – 5 - Print C Step – 6 - END Design

Algorithm An algorithm to convert temperature from Centigrade to Fahrenheit Step – 1 - START Step – 2 - Input C Step – 3 - F = 0 Step – 4 - F = 9 * C / 5 + 32 Step – 5 - Print F Step – 6 - END Design

Flowchart Symbols Symbols Meaning Symbols Meaning Terminal Start / End Decision Making Processing Input / Output Document / Hard Copy Storage Disk Connector Different page connector

Flowchart Diagram

Program Definition A program consists of a series of instructions that a computer processes to perform the required operation. Set of computer programs that describe the program are called software. The process of software development is called Programming and the person who creates the computer programs is called Programmer. A program is a set of instruction written by the programmer. A collection of a programs are known as software.

Program Requirements Thus, in order to design a program, a programmer must determine three basic requirements:  The instructions to be performed.  The order in which those instructions are to be performed.  The data required to perform those instructions.

Program Example^ -^1 #include int main() { int A, B, C = 0 ; printf("Enter A = "); scanf("%d",&A); printf("Enter B = "); scanf("%d",&B); C = A + B; printf("Sum C = %d",C); return 0 ; }

OUTPUT

Enter A = 20 Enter B = 10 Sum C = 30

Program Characteristic Any computer program should have the following characteristics.  Accuracy – Any calculation made in the program should be correct and accurate.  Clarity – It refers to the overall readability of the program which helps the user to understand the underlying program logic easily without much difficulty.  Modularity – When developing any program, the task is divided into several modules or subtasks. These modules are developed independently i.e. each task does not depend on the outer task.