76b33010-6fdb-4e4f-9426-94403f16f741
76b33010-6fdb-4e4f-9426-94403f16f741
1.0 Pengaturcaraan
Cost: The price to acquire, produce, and maintain. This often involves money,
time, energy, and expenses.
Normal Project: Completed within allocated time and cost.
Crashing Cost: Maximum effort to complete a project in the shortest time,
which increases costs.
Time: Refers to completing projects within the set timeframe. Delays increase
costs, and needing to complete a project quickly also increases costs.
Resources: Stocks, money, raw materials, staff, and other assets used by an
organization to function effectively and generate results.
Resource Planning: Management's responsibility to optimize decisions.
Careful planning avoids waste.
Resource Scheduling: Prevents project delays. Resource shortages slow
down project completion and increase costs.
Problem-solving steps:
1.2 Algoritma
1. A set of instructions for solving a problem.
2. Detailed instructions that can be followed.
3. Can be refined by adding details.
Page 1
Created by Turbolearn AI
Characteristics of an algorithm:
Clear details
Executable
Has limitations
Identify input data, processes to change data values into information, and
output displays.
Example of IPO:
Pseudocode
Flowcharts
Page 2
Created by Turbolearn AI
1.2 Pseudocode
1. Not a computer programming language.
2. Instructions written in everyday language.
3. Each instruction is a mathematical expression, logical expression, control
structure, or use of computer functions.
4. Each instruction is placed in a new line with a serial number.
1.2 Flowchart
The image above shows a flowchart illustrating the steps to calculate the area of a
circle, beginning with "Start", reading in the radius, setting pi to 3.142, calculating the
area, displaying the area, and concluding with "End".
Page 3
Created by Turbolearn AI
Syntax Error
Logic Error
Runtime Error
Error Description
Syntax Does not exist in the algorithm. Occurs due to carelessness when using
Error the programming language. Usually found automatically by the compiler.
Occurs because the software does not perform its intended function, is
Logic Error
incomplete, or produces inaccurate output.
Runtime Errors that arise when the program is run, for example, the program
Error cannot be started, is very slow, or is unresponsive.
Page 4
Created by Turbolearn AI
1 - -
2 100 100
3 50 -
4 200 -
5 250 -
6 250 250
7 - -
1. Start
2. Input z = 100
3. z = z / 2
4. z = z * 4
5. z = z * 0.25 + z
6. Display z
7. End
Page 5
Created by Turbolearn AI
1 - - - -
2 12 - - -
3 12 88 - -
4 12 88 100 12 + 88 = 100
5 12 88 100 Jumlah = 100
6 - - - -
Page 6
Created by Turbolearn AI
The value of a variable always changes during data processing and will not
hold any value after the program ends.
The computer uses the variable name as a reference to find the variable's value
in its memory.
The value of a constant is fixed and will not change during the programming
process.
Used when programmers want to declare a value that will not change.
Data types can be categorized into 2 classes: primitive data and non-primitive
data.
Page 7
Created by Turbolearn AI
Page 8
Created by Turbolearn AI
Data Type
Integer Includes all numbers that do not have fraction or decimal values.
Real
Consists of all numbers that have a decimal point or fractional part.
Number
Data in the form of spaces, text, words, or values containing a sequence
Character
of characters or symbols.
Boolean Data in the form of a choice, i.e., choosing one of something true or false.
Page 9
Created by Turbolearn AI
Page 10
Created by Turbolearn AI
Data
Value Example
Type
Type of
Statement
Examples:
Page 11
Created by Turbolearn AI
String x;
x = “ Hello ”;
double p;
p = 0.123;
float w;
w = 561.123f;
int p;
int q;
int r;
p = q =r = 255;
(30 – 5 + ((2*3) / 3)
Example
Notation Program Example
Output
import java.util.Scanner;
Scanner input = new Scanner (System.in);
Page 12
Created by Turbolearn AI
import java.util.Scanner ;
public class luasSegiTiga {
public static void main (String [] args) {
Scanner input = new Scanner (System.in);
System.out.println (“Please enter the base value: ” );
int tapak = input.nextInt();
System.out.println (“Please enter the height value: ” );
int tinggi = input.nextInt();
double luas = (1.0/2) * tapak * tinggi ;
System.out.println (“Area
```## Struktur Kawalan (Control Structures)
 and shows the dif
if () { }
*Example:*
Page 13
Created by Turbolearn AI
if () { } else { }
*Example:*
Page 14
Created by Turbolearn AI
 {
int number = 15;
if (number > 0)
System.out.println(“This number is a positive integer”);
else
System.out.println(“This number is not a positive integer”);
}
}
Output:
Output:
Page 16
Created by Turbolearn AI
Output:
Output:
Page 17
Created by Turbolearn AI
Output:
You passed
Output:
Page 18
Created by Turbolearn AI
for Loop
Output:
12345678910.
Output:
5049
Output:
Page 19
Created by Turbolearn AI
1,3,5,7,9,11,15,17,19,23,25,27,29
Output:
while Loop
Output:
5,4,3,2,1
Page 20
Created by Turbolearn AI
import java.util.Scanner;
import java.util.Scanner;
Sample Interaction:
do-while Loop
Page 21
Created by Turbolearn AI
Output:
1 X 3 = 3
2 X 3 = 6
3 X 3 = 9
4 X 3 = 12
5 X 3 = 15
6 X 3 = 18
7 X 3 = 21
8 X 3 = 24
9 X 3 = 27
10 X 3 = 30
11 X 3 = 33
12 X 3 = 36
import java.util.Scanner;
Sample Interaction:
Page 22
Created by Turbolearn AI
6
7
9
3
6
The total is 31.0
import java.util.Scanner;
Sample Interaction:
5
7
Beza = 2
Type YA to continue
YA
5
9
Type YA to continue
t
Page 23
Created by Turbolearn AI
i += 1 i = i + 1
i += 2 i = i + 2
i += 3 i = i + 3
i -= 1 i = i – 1
i -= 2 i = i – 2
i -= 3 i = i - 3
Page 24
Created by Turbolearn AI
import java.util.Scanner;
Page 25
Created by Turbolearn AI
import java.util.Scanner;
Page 26
Created by Turbolearn AI
import java.util.Scanner;
public class dadurambang {
public static void main (String [] args) {
int i ;
int diceNo;
int Kira1 =0, Kira2 =0, Kira3 =0, Kira4 =0, Kira5 =0, Kira6 =0;
double percen1 = 0 , percen2 = 0 , percen3 = 0 , percen4 = 0 , per
int jumlahKiraan = 0;
Scanner scanner = new Scanner (System.in);
Boolean flag = true;
do {
for (i = 1; i <=20 ; i++ ) {
diceNo = (int) (Math.random() * 6 + 1) ;
switch (diceNo) {
case 1 : Kira1++ ; break;
case 2 : Kira2++ ; break;
case 3 : Kira3++ ; break;
case 4 : Kira4++ ; break;
case 5 : Kira5++ ; break;
case 6 : Kira6++ ;
}
}
jumlahKiraan = Kira1 + Kira2 + Kira3 + Kira4 + Kira5 + Kira6;
percen1 = (double) Kira1/jumlahKiraan * 100;
percen2 = (double) Kira2/jumlahKiraan * 100;
percen3 = (double) Kira3/jumlahKiraan * 100;
percen4 = (double) Kira4/jumlahKiraan * 100;
percen5 = (double) Kira5/jumlahKiraan * 100;
percen6 = (double) Kira6/jumlahKiraan * 100;
System.out.println () ;
System.out.println (“ Dice Number 1 = ” + percen1 + “ % ”);
System.out.println (“ Dice Number 2 = ” + percen2 + “ % ”);
System.out.println (“ Dice Number 3 = ” + percen3 + “ % ”);
System.out.println (“ Dice Number 4 = ” + percen4 + “ % ”);
System.out.println (“ Dice Number 5 = ” + percen5 + “ % ”);
System.out.println (“ Dice Number 6 = ” + percen6 + “ % ”);
System.out.println () ;
System.out.println (“ ---------------------------------”);
System.out.println (“ Type ya to continue”);
if (!scanner.next().equals(“ya”)) {
flag = true;
}
} while ( flag)
}
}
Page 27
Created by Turbolearn AI
Komen (Comments)
Clearly written in two to three short lines to describe the function of the code
and fit the coding column space.
Page 28
Created by Turbolearn AI
Page 29
Created by Turbolearn AI
Program Sections)
INPUT OUTPUT
The compiler ignores all text starting with // until the last text of the
//
same line.
/* */ The compiler ignores all text within /* to */ even on different lines.
Documentation comments. The compiler ignores these comments just
/** */
like /* comments.
Page 30
Created by Turbolearn AI
Page 31
Created by Turbolearn AI
Data can be arranged in arrays and vectors, linked lists, stacks, and queues.
Use a systematic structure for variables and instructions when developing a
program.
Variables can be broken down into "small groups" called ARRAYS.
Computer instructions can also be broken down into small groups called
FUNCTIONS.
Related groups are called only when needed.
This diagram shows visual representations of Vectors, Matrices, Arrays, Data Frames,
and Lists.
dataType [ ] arrayName;
arrayName = new dataType [ arraySize];
Example:
int [ ] scoreList ;
scoreList = new int [ 6 ];
Page 32
Created by Turbolearn AI
scoreList [ 0 ] = 34 ;
scoreList [ 1 ] = 56 ;
scoreList [ 2 ] = 78 ;
scoreList [ 3 ] = 89 ;
scoreList [ 4 ] = 56 ;
scoreList [ 5 ] = 95 ;
Elements
34 56 78 89 56 95
Index
0 1 2 3 4 5
Alternate Declaration:
Example Program:
Page 33
Created by Turbolearn AI
package perisianSaya;
Page 34
Created by Turbolearn AI
Easy to reuse
Easy to test, debug, and repair
Allows tasks to be divided among different group members
Easier to handle computer projects
Complex projects become simple
Keyword Description
Subprocedures
Page 35
Created by Turbolearn AI
The relationship between two subprocedures is that of a caller and a callee. The
caller invokes the callee's name within its body.
Parameters must be declared during the subprocedure definition and declared within
the parentheses of the parameter container. The declaration of parameters is similar
to that of variables. There is no limit to the number of parameters, and their sequence
depends on the programmer.
Here are some examples that demonstrate including and excluding parameters:
Page 36
Created by Turbolearn AI
For those that only return control, the keyword void is used.
If a subprocedure returns data, the last line in the subprocedure body has a
return statement and the data to be returned to the caller.
The subprocedure name does not have void as the return data type. Instead, the
data type corresponding to the data being returned is declared in the syntax.
The name of a subprocedure that returns data is usually prefixed with get.
static void subAturcara ( ) { } Does not return data. Only control is returned.
static int subAturcara ( ) { } Returns data of integer type.
static double subAturcara ( ) { } Returns data of double type.
static string subAturcara ( ) { } Returns data of string type.
Procedures
Page 37
Created by Turbolearn AI
ASPECT OF
FUNCTION PROCEDURE
COMPARISON
SYNTAX EXPLANATION
Modular Programming
Page 38
Created by Turbolearn AI
The program for the example above is a console application. Variables (name, grade,
marks) are declared as global variables, accessible by all subprocedures. The
procedures main(), getNama(), getMarkah(), setGred(), and paparInfo() can read and
write to the same set of variables. The main() procedure does not contain many
algorithm statements because those statements have been placed into
subprocedures. Calling subprocedures should follow a logical sequence.
Arrays as Parameters
Arrays are used as parameters for large amounts of data. Ensure that the
subprocedure can accept array parameters. Declaration is done in the subprocedure
header, and a for loop is needed to assign or access values of elements in the array.
Elements in an array can be changed directly from any subprocedure; therefore, the
array variable does not need to be returned to the caller.
In this example, an empty number array is declared in the main() procedure, and a
call is made to the setSenaraiRawak procedure. In setSenaraiRawak, the empty array is
assigned with random values generated by math.random. The values of the elements
are displayed in both the subprocedure and the main() procedure.
Page 39
Created by Turbolearn AI
SDLC Models:
Waterfall
RAD (Rapid Application Development)
Iterative
Spiral
Agile
Hybrid (Combination Model)
SDLC Phases
The SDLC phases are commonly used as a model for application development,
mirroring the processes in SDLC. It is one of the earliest models, easy to understand
and manage, containing 5 phases where one phase needs to be completed before
moving to the next.
Analysis
Identifying program requirements and the reasons for building a program. Systematic
steps must be followed to solve problems, and it is important to clearly understand
the problem statement.
Page 40
Created by Turbolearn AI
Hourly Rate, 1. Get hourly rate. 2. Get hours worked. 3. Calculate Staff
Hours Worked Staff Salary = hourly rate X hours worked Salary
Design
Created after IPO analysis, this phase looks at potential solutions and determines the
most effective and efficient one, building the best solution.
Pseudocode Example:
1. Start
2. Read hourly rate (kadarsj)
3. Read hours worked (bilJam)
4. Calculate staff salary = kadarsj * bilJam
5. Display staff salary
6. End
Implementation
The goal is to transform the design into a program that can be installed on hardware
and is ready to execute the solution, building and producing a system that can solve
the problems faced. Application development activities involve coding.
Page 41
Created by Turbolearn AI
Testing
Ensuring all requirements are met, all coding functions as required, and all modules
can function when combined. It involves feedback from system users for correction
and improvement, engaging users fully in the development stage.
Detecting omissions.
Helping the project team document by detecting user errors.
Storing test results as proof of system development completion.
Page 42
Created by Turbolearn AI
Documentation
A process of collecting data, gathering information, and summarizing,
such as running test reports, flowcharts, program code, and IPO charts.
These documents are important for system user reference, IT officers, and new staff
in each phase. Complete documentation of the project phase from the beginning in
each phase will be used as a reference for the next phase.
Page 43