Professional Documents
Culture Documents
STUDENT 01slide Week 1
STUDENT 01slide Week 1
Programming Concept
Week 1
Student Guide
Agenda
1. Autonomous Professional Profile
4. Syllabus
3
Autonomous Professional Profile
Information System Study Program
1. Having excellent skills as an Information System Professional and ability to lead
innovation at Enterprise through Information System Technology utilization.
2. Having technopreneurial quality to develop and lead an independent business
by incorporating various technologies and cross-disciplinary approaches.
3. Having excellent ability in knowledge transfer to advance the Information
System field through the publication of innovative, creative, and applicable
scientific works.
4
Program Learning Outcome
Bachelor of Informatics
• PLO-1 Able to analyze complex problems in the field of informatics and apply principles of informatics and other relevant
disciplines to identify their solutions by taking into account insights from the advancements of trans-disciplinary fields.
• PLO-2 Able to design, implement, and evaluate computing-based solutions that meet the computing needs of a disciplinary
program.
• PLO-3 Able to communicate proficiently in various professional contexts.
• PLO-4 Able to comprehend professional responsibilities and to conduct assessment based on appropriate information in
computing practices and legal and ethical principles.
• PLO-5 Able to effectively conduct the role of team leader or member in activities that are in accordance with the discipline of
the study program.
• PLO-6 Able to apply computer science theories and the basis of software development to develop computing-based solutions.
• PLO-7 Able to analyze, design, and develop a Startup Business supported by information technology.
• PLO-8 Able to comprehend the basics of research and scientific writing in the field of informatics.
5
Program Learning Outcome
Bachelor of Information System
• PLO 1 Possessing the ability to identify and analyze complex problems in the field of computing by utilizing principles of computing,
supported by other related fields, to develop innovative and creative solutions in accordance with the development of cross-disciplinary fields
• PLO 2 Possessing the skills to design computing-based solutions and to implement them by applying modern style techniques in order to
offer complete solutions based on appropriate requirements, and to evaluate the solutions in a certain domain
• PLO 3 Possessing the proficiency to communicate properly and correctly, both orally and in writing, in a variety of domains
• PLO 4 Possessing a professionally responsible attitude and the ability to conduct assessments based on data and information in computing
practices while paying attention to ethical and legal norms
• PLO 5 Possessing the capability to be effective and efficient leaders or team members in a variety of activities, that are relevant to both the
field of information systems and those of other fields
• PLO 6 Possessing the ability to support the concept, delivery, utilization, and management of information systems within an industrial and
business environment in particular, as well as those of other environments
• PLO 7 Possessing an entrepreneurial attitude and the capability to design an independent business/start-up related to information systems
• PLO 8 Being able to learn independently as a lifelong study, and to generate and transfer cutting-edge scientific knowledge
6
Course Learning Outcome
• [PLO1 - CLO 1] Able to analyze problem in the environment and identify possible
solution that can be deliver through concepts of programming and possible programming
capability advancements of trans-disciplinary fields
• [PLO2 - CLO 2] Able to design, implement, and evaluate problem in the perspective of
programming, and present effective and efficient solutions that meet the computing
standards and serve as solution towards identified problem
• [PLO6 - CLO 3] Able to apply concept of programming theories and the basis of software
development to develop programming-based solutions
7
Team of Lecturer
8
Class Marks
• Attendance = 5%
• Class Exercises & Participations = 15 %
• Case Studies and Assignments = 15%
• Projects = 15%
• Midterm = 20%
• Final Exam = 30%
https://ecampus.president.ac.id
Student with absent more than 4 may not be
allowed to sit for Final Exam.
9
Class Agreements
1. Attendance will be done before the class starts
2. No tolerance form lateness. Students that missed
the attendance period will be counted as absent
though permitted to enter the class
3. Importance to uphold manners in class. Students
need to seek for approval prior leaving the class
(i.e. to go to toilet, urgent phone calls)
4. No Slippers!
5. Late assignment submissions will receive a penalty
score as a score reduction. We honor those who
submit on-time
6. Plagiarism and cheating are serious offenses which
results in zero (non-negotiable once proven) 10
Course Syllabus
Week 1 [4-8 September] : Introduction to Programming, Identifiers and Variables, Data Types variable,
Constant, Assignments statement and expressions, Mathematical operator +, -, *, /, \
Week 2 [11-15 September] : Introduction to Flowchart, Selections, Boolean Data Types, If – Else and
multi ways of If – Else statement, Logical Operator, Conditional Operator,
Week 3 [18-22 September] : Nested If-Else statement, Switch Statements, Quiz 1
Week 4 [25-29 September] : Mathematical Functions, Characters and Strings, String types, length and
concatenations.
Week 5 [2-6 October] : Introduction to Loops, While Loop and Do-While Loop, Loop Control (when
to break, and to continue), Nested While Loop
Week 6 [9-13 October] : For Loop, Increment, Decrement, Loop Control (with increment ++; and
decrement --), Nested For Loop, Quiz 2
Week 7 [16-20 October] : Implementation of Selection and Repetition in Problem Solving. Output
Formatting. Class Case Studies.
11
Week 8 [23-27 October] : Midterm
Course Syllabus
Week 9 [30 Oct – 2 November] : Introduction to Single Dimensional Array, Array Basics, Copying
Arrays, Counting Arrays
Week 10 [6– 10 November]: Searching Arrays, Sorting Arrays, Quiz 3
Week 11 [13 – 17 November] : Introduction to Multidimensional Arrays, Processing Two-
Dimensional Arrays
Week 12 [20 – 24 November] : Passing values between Two-Dimensional Arrays, Implementation
2D Arrays in Problem Solving. Class Case Studies.
Week 13 [27 Nov – 1 December] : Programming Project: from Requirements, Flowchart, to Coding
Implementation utilizing Selection, Loop and Arrays.
Week 14 [4 – 8 December] : Programming Project : Hands-on. Realizing Programming Project. Pt. 1
Dealing with User Input and on Monitor output.
Week 15 [11 – 15 December]: Programming Project : Hands-on. Realizing Programming Project. Pt.
2 Dealing with from txt/csv data input and txt/csv data output
12
Week 16 [ 18-20 December]: Final Exam
Week 1 : Introduction to Programming,
Identifiers and Variables, Data Types variable,
Constant, Assignments Statement and
Expressions, Mathematical operator +, -, *, /, \
13
Programs
Computer programs, known as software, are instructions to the computer.
14
Popular IDEs
https://www.eclipse.org/downloads/packages/
15
A Simple Program
Listing 1.1
// This program prints Welcome to Java!
public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
16
Creating, Compiling, and Running Programs
17
Two More Simple Examples
18
Special Symbols
Character Name Description
" " Opening and closing Enclosing a string (i.e., sequence of characters).
quotation marks
; Semicolon Marks the end of a statement.
19
Blocks
• A pair of braces in a program forms a block that groups components of
a program.
20
Block Styles
Use end-of-line style for braces.
Next-line public class Test
style {
public static void main(String[] args)
{
System.out.println("Block Styles");
}
}
End-of-line
style
public class Test {
public static void main(String[] args) {
System.out.println("Block Styles");
}
}
21
Programming Errors
• Syntax Errors
• Detected by the compiler
• Runtime Errors
• Causes the program to abort
• Logic Errors
• Produces incorrect result
22
Syntax Errors
public class ShowSyntaxErrors {
public static main(String[] args) {
System.out.println("Welcome to Java);
}
} Identify the error!
23
Runtime Errors
public class ShowRuntimeErrors {
public static void main(String[] args) {
System.out.println(1 / 0);
}
}
Identify the error!
24
Logic Errors
public class ShowLogicErrors {
public static void main(String[] args) {
System.out.println("Celsius 35 is Fahrenheit degree ");
System.out.println((9 / 5) * 35 + 32);
}
} Identify the error!
25
Introducing Programming with an Example
Listing 2.1 Computing the Area of a Circle
This program computes the area of the circle.
26
animation
// Assign a radius
radius = 20;
// Compute area
area = radius * radius * 3.14159;
// Display results
System.out.println("The area for the circle of radius " +
radius + " is " + area);
}
}
27
animation
// Compute area
area = radius * radius * 3.14159;
// Display results
System.out.println("The area for the circle of radius " +
radius + " is " + area);
}
} 28
animation
// Assign a radius
radius = 20;
// Compute area
area = radius * radius * 3.14159;
// Display results
System.out.println("The area for the circle of radius " +
radius + " is " + area);
}
} 29
animation
// Assign a radius
compute area and assign it
radius = 20;
to variable area
// Compute area
area = radius * radius * 3.14159;
// Display results
System.out.println("The area for the circle of radius " +
radius + " is " + area);
}
}
30
animation
// Assign a radius
radius = 20; print a message to the
console
// Compute area
area = radius * radius * 3.14159;
// Display results
System.out.println("The area for the circle of radius " +
radius + " is " + area);
}
}
31
Variables
// Compute the first area
radius = 1.0;
area = radius * radius * 3.14159;
System.out.println("The area is “ + area + " for radius
"+radius);
33
Assignment Statements
x = 1; // Assign 1 to x;
radius = 1.0; // Assign 1.0 to radius;
a = 'A'; // Assign 'A' to a;
34
Declaring and Initializing
in One Step
• int x = 1;
• double d = 1.4;
35
Named Constants
final datatype CONSTANTNAME = VALUE;
36
Rule for Identifiers
• An identifier is a sequence of characters that consist of letters, digits,
underscores (_), and dollar signs ($).
• An identifier must start with a letter, an underscore (_), or a dollar sign
($). It cannot start with a digit.
• An identifier cannot be a reserved word. (See Appendix A, “Java
Keywords,” for a list of reserved words).
• An identifier cannot be true, false, or null.
• An identifier can be of any length.
37
Exercise 1.1 Time!
1. Turn off devices, place your laptops a side
2. Take a piece of paper
3. Lets do it!
38
Problem: Converting Temperatures
Write a program that converts a Fahrenheit degree to Celsius using the
formula: celsius = ( 5 )( fahrenheit − 32)
9
39
Reading Input from the Console
1. Create a Scanner object
Scanner input = new Scanner(System.in);
40
Numerical Data Types
Name Range Storage Size
Positive range:
41
4.9E-324 to 1.7976931348623157E+308
Reading Numbers from the Keyboard
Scanner input = new Scanner(System.in);
int value = input.nextInt();
Method Description
42
Numeric Operators
Name Meaning Example Result
+ Addition 34 + 1 35
% Remainder 20 % 3 2
43
Integer Division
+, -, *, /, and %
5 / 2 yields an integer 2.
5.0 / 2 yields a double value 2.5
45
NOTE
Calculations involving floating-point numbers are approximated
because these numbers are not stored with complete accuracy. For
example,
System.out.println(1.0 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1);
displays 0.5000000000000001, not 0.5, and
System.out.println(1.0 - 0.9);
displays 0.09999999999999998, not 0.1. Integers are stored precisely.
Therefore, calculations with integers yield a precise integer result.
46
Exponent Operations
System.out.println(Math.pow(2, 3));
// Displays 8.0
System.out.println(Math.pow(4, 0.5));
// Displays 2.0
System.out.println(Math.pow(2.5, 2));
// Displays 6.25
System.out.println(Math.pow(2.5, -2));
// Displays 0.16
47
Number Literals
A literal is a constant value that appears directly in the program. For
example, 34, 1,000,000, and 5.0 are literals in the following
statements:
int i = 34;
long x = 1000000;
double d = 5.0;
48
double vs. float
The double type values are more accurate than the float type values. For
example,
System.out.println("1.0 / 3.0 is " + 1.0 / 3.0);
16 digits
49
Arithmetic Expressions
3 + 4 x 10( y − 5)( a + b + c ) 4 9+ x
− + 9( + )
5 x x y
is translated to
50
Demo: Displaying Time
A program that obtains minutes and remaining seconds
from seconds.
51
Demo: Displaying Current Time
Write a program that displays current time in GMT in the format
hour:minute:second such as 1:45:19.
The currentTimeMillis method in the System class returns the current
time in milliseconds since the midnight, January 1, 1970 GMT. (1970
was the year when the Unix operating system was formally
introduced.) You can use this method to obtain the current time, and
then compute the current second, minute, and hour as follows.
Elapsed
time
Time
Unix Epoch Current Time
01-01-1970 System.currentTimeMills()
00:00:00 GMT
52
Augmented Assignment Operators
53
Numeric Type Conversion
Consider the following statements:
byte i = 100;
long k = i * 3 + 4;
double d = i * 3.1 + k / 2;
range increases
54
Type Casting
Implicit casting
double d = 3; (type widening)
Explicit casting
int i = (int)3.0; (type narrowing)
int i = (int)3.9; (Fraction part is truncated)
55
Demo: Keeping Two Digits After Decimal Points
Write a program that displays the sales tax with two digits after the
decimal point.
56
Exercise 1.2 Time!
1. Turn off devices, place your laptops a side
2. Take a piece of paper
3. Let’s do it!
57
Problem:
Computing Loan Payments
This program lets the user enter the interest
rate, number of years, and loan amount, and
computes monthly payment and total
payment.
loanAmount monthlyInterestRate
monthlyPayment =
1− 1
(1 + monthlyInterestRate) numberOfYears12
58
Common Errors and Pitfalls
Common Error 1: Undeclared/Uninitialized
Variables and Unused Variables
Common Error 2: Integer Overflow
Common Error 3: Round-off Errors
Common Error 4: Unintended Integer Division
Common Error 5: Redundant Input Objects
60
Common Error 2: Integer Overflow
61
Common Error 3: Round-off Errors
System.out.println(1.0 - 0.9);
62
Common Error 4: Unintended Integer
Division
int number1 = 1; int number1 = 1;
int number2 = 2; int number2 = 2;
double average = (number1 + number2) / 2; double average = (number1 + number2) / 2.0;
System.out.println(average); System.out.println(average);
(a) (b)
63
Common Pitfall 1: Redundant Input Objects
65
Problem: Monetary Units
• Write a program lets the user enter the
amount in representing Rupiah and output a
report listing the monetary equivalent in:
• Hundred thousand rupiah
• Fifty thousand rupiah
• Twenty thousand rupiah
• Ten thousand rupiah
• Five thousand rupiah
• Two thousand rupiah
• One thousand rupiah
• Coins. ComputeChange
66
Class Exercise 1 Compilations
• Take a picture of your exercises 1.1, exercises 1.2 and exercises 1.3
• Hand over your exercises next week before the class start.
• Compile your exercises in one PDF and upload to e-campus
(given later, before 10 September 2023).
• Late upload in e-campus will results in 50% marks off per day.
67