0% found this document useful (0 votes)
11 views66 pages

Java Programming Practicum Report 2019

This practical report discusses the Java programming laboratory conducted at the UNPAB computer lab. This report contains an introduction to Java and NetBeans, operators, classes, objects, methods, loops and branching structures, as well as object-oriented programming. This report also includes the results of the practical work conducted on eight learning modules and an analysis of the practical results.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views66 pages

Java Programming Practicum Report 2019

This practical report discusses the Java programming laboratory conducted at the UNPAB computer lab. This report contains an introduction to Java and NetBeans, operators, classes, objects, methods, loops and branching structures, as well as object-oriented programming. This report also includes the results of the practical work conducted on eight learning modules and an analysis of the practical results.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PRACTICE REPORT

JAVA PROGRAMMING LANGUAGE

ISLAMIC UNIVERSITY OF RIAU

FACULTY OF ENGINEERING

DEPARTMENT OF COMPUTER ENGINEERING

PEKANBARU

2018/2019
FOREWORD

Peace be upon you.

Praise and thanks to Allah SWT for His grace and guidance.

I can complete this Laboratory Report. Also, sending blessings and greetings.

I dedicate this to the Prophet Muhammad SAW along with his family, companions, and

its people.

This report is a series of practical experiments conducted at

The Computer Laboratory of UNPAB aims for students to be more

understanding learning in the Java Programming course, and

directly applying the knowledge gained during this course.

This report is also made to fulfill the final assignment of the Language course.

Java programming in Semester 5.

I realize that in this practicum report there are still

shortcomings due to my limitations as a human. Therefore, I hope

constructive criticism and suggestions to make this report even better. I

I hope this practical report can be beneficial, especially for me and ...

for the readers.

Peace be upon you and God's mercy and blessings.

Pekanbaru, May 14, 2019

I
TABLE OF CONTENTS

FOREWORD ........................................................................................ i

TABLE OF CONTENTS....................................................................................................... ii

CHAPTER I: INTRODUCTION

1.1 General

1.2 Background.................................................................................... 2

Objectives of the Practicum

CHAPTER II: DISCUSSION

2.1 Theoretical Foundation .................................................................................... 4

2.1.1 Introduction to Java and NetBeans.................................................... 4

2.1.2 Operator

2.1.3 Class, Object, and Method

2.1.4 Looping and Branching Structure ......................................... 16

2.1.5 Object-Oriented Programming................................................ 17

CHAPTER III: RESULTS OF EXPERIMENT/EXPERIMENTATION

3.1 Practicum Module 2.............................................................................. 19

ii
3.2 Internship Module 3.............................................................................. 26

3.3 Internship Module 4.............................................................................. 28

3.4 Internship Module 5...................................................... 31

3.5 Internship Module 6 .............................................................................. 36

3.6 Internship Module 7............................................................. 30

3.7 Internship Module 8.............................................................................. 45

CHAPTER IV: ANALYSIS OF EXPERIMENT RESULTS

4.1 Analysis of Module 2 .................................................................................. 52

4.2 Analysis of Module 3 .................................................................................. 52

4.3 Analysis of Module 4 .................................................................................. 53

4.4 Analysis of Module 5 .................................................................................. 54

4.5 Analysis of Module 6 .................................................................................. 56

4.7 Analysis of Module 7 .................................................................................. 57

4.8 Analysis of Module 8 .................................................................................. 58

CHAPTER V: CONCLUSION

BIBLIOGRAPHY . ....................................................................................... v

iii
CHAPTER I

INTRODUCTION

1.1 GENERAL

Java Programming Language is the study of

a programming that can create all forms of desktop applications,

Web and others. Java is also a high-level programming language.

object-oriented (OOP) and can run on various platforms

operating system. Java was developed not to focus on just one system

but developed for various operating systems and is open source.

Java programming consists of parts called classes. The class is then

is a collection of methods that perform tasks and

returning information after completing their task. Java programmers

many take advantage of the class pool in the class library, which

referred to as Java Application Programming Interface (API). Classes - classes

this is organized into one group called a package.

The Java API has provided adequate functionality to create

advanced application. So there are two things to learn in Java, namely

learning the syntax of the Java language and how to use classes in it

Java API.

1
1.2 BACKGROUND

The current development of technology is experiencing very rapid growth.

rapid and has brought changes to human life. In

human life is greatly influenced by information, where information

it can be obtained through science and technology.

Therefore, we need to learn how to create and

developing information systems. With the technology that is already available

using programming languages.

Java is a programming language that can be run on

various platforms, including on mobile phones (Smartphones). Language

this programming was initially created by James Gosling while still joining

Sun Microsystems is currently part of Oracle, which was released

in 1995. This programming language is a development of the syntax

that is present in C and C++ programming, but with a model syntax

objects are much simpler. Java-based applications generally can

run on various Java Virtual Machines (JVM). Java is a language

general or non-specific programming, Currently, Java is

the most popular programming languages that are widely used

utilized in the development of various desktop applications or

web-based application.

2
1.3 PURPOSE OF THE PRACTICUM

As the final assignment for the Java programming language course

Students can learn and apply programs from Netbeans

Students can learn about the function of Operators in

Java Programming Language

Students can understand and learn what is meant by

Class, Object, and Method

Students can understand and learn what is meant by

Looping and Branching Structures in the Java Programming Language

Students can understand what is meant by Object-Oriented Programming.

Objects in the Java Programming Language.

3
CHAPTER II

DISCUSSION

2.1 THEORETICAL FRAMEWORK

2.1.1 Introduction to Java and NetBeans

Java is a programming language that is based on

Object Oriented Programming. Java was created through

development of the programming language C++ that is designed

so simple and portable (can be run on various

platform and operating system). Programs produced with the language

Java can be an applet (a small application that runs on the web)

either a browser or as a standalone application that is run with

Java Interpreter program. Example program written in the language

Java is HotJava which is a web browser.

Netbeans is one of the IDE applications that is used

programmer as an editor for writing, compiling, searching

errors, and spreading the program. Netbeans is written in language

Java can also support other programming languages.

Netbeans is included in the type of Open-based Operating System.

Source (open to the public).

4
A. Additional Packages for NetBeans IDE:

A.1 NetBeans Mobility Pack

NetBeans Mobility Pack is a tool for developing applications

that runs on mobile devices, generally mobile phones,

but also includes PDA and others. NetBeans Mobility Pack can

used for writing, testing, and debugging applications for devices

movement that uses Java Micro Edition platform technology

(Java ME platform).

This package integrates support for Mobile Information

Device Profile (MIDP) 2.0, Connected Limited Device Configuration (CLDC)

1.1, and Connected Device Configuration (CDC). Emulator from third parties

can be easily integrated for a more testing environment

solid. The NetBeans Mobility Pack is currently available in two clusters that

different, one contains CDC and the other CLDC.

A.2 NetBeans Profiler

NetBeans Profiler is a tool for optimizing Java applications.

helps find memory leaks and optimize speed.

This profiler is based on an old research project by Sun Laboratories.

entitled Jfluid. The research revealed certain techniques that can

used to reduce the overhead of Java application profiling process. Wrong

one of the techniques is dynamic byte code instrumentation, which

useful for profiling large Java applications. By using

5
dynamic bytecode instrumentation and additional algorithms, Netbeans

The profiler can gather runtime information about the application that is too large.

or complex for other profilers. NetBeans IDE 6.0 will support

Profiling Point that allows us to profile the exact point of

execution and measuring the execution time.

A.3 NetBeans C/C++ Pack

The NetBeans C/C++ Pack adds support for developers.

C/C++ for NetBeans IDE 5.5. This package allows developers

using a set of compilers and tools of one's own along with

NetBeans IDE for building native applications for MS Windows, Linux,

and Solaris. This package makes the editor recognize the C/C++ language and

providing project templates, dynamic class browser, support

the creation of files and debugger functionality. Developers can also

developing the package with additional functionalities

alone.

A.4 NetBeans Enterprise Pack

NetBeans Enterprise Pack expands support for

development of corporate applications and web services in NetBeans IDE 5.5.

This Enterprise Pack enhances the ability to write, test,

and debug applications with service-oriented architecture

Architecture) uses XML, BPEL, and Java web service. This package

6
adding visual design tools for UML modeling, XML schemas, and

web service orchestration, as well as support for web services with

using a secure identity. This package also installs and

configuring the required runtime, including the BPEL engine and server

integrated identity management with Sun Java System Application

Server.

A.5 NetBeans Ruby Pack

The upcoming version of NetBeans 6.0 will allow IDE development.

using Ruby and Jruby, as well as Rails for two implementations

Other Ruby. The NetBeans Ruby Pack preview has been available since the Milestone 7 release.

NetBeans [Link] Pack includes editor functionalities such as:

Basic editing

Syntax coloring for Ruby

Code Equipment

Occurrence highlighting

Integrated documentation pop-up for calling Ruby API

Semantic analysis with highlighting local parameters and variables that

not used.

A.6 NetBeans JavaScript Editor

NetBeans JavaScript Editor provides extended support

regarding JavaScript and CSS. Its features include:

7
JavaScript Editor

Syntax highlighting

Code equipment for native objects and functions

All features in the NetBeans editor

Automatic creation of JavaScript class frameworks

Creation of AJAX call from template

CSS editor extension

Code equipment for style names

Quick navigation through the navigator panel

The appearance of CSS rule declaration in List View

File structure appearance in Tree View

Sort the outline view by name, type, or declaration order

(List & Tree)

Creation of rule declaration (only Tree)

- Refactoring some rule names (only Tree)

A.7 Localization

Since January 2007, the simplified Chinese language package, Chinese

traditional, German, Japanese, Portuguese (Brazil) and Spanish have been made available for

NetBeans 5.5.1. In the meantime, the language packs for Albanian, Azerbaijani, Czech,

The Netherlands, Greece, Indonesia, Italy, and Sweden are in the process

execution.

8
B. Databases supported by Netbeans include:

B.1 JDBC

It is the standard specification of the JavaSoft API (Application

Programming Interface) that allows Java programs to access

database management system. JDBC API consists of a set of interfaces and classes

written in the Java programming language. JDBC API Using

standard interfaces and classes, programmers can write applications that

connect to the database, send the question written in SQL (Structured

Query Language), and processing the results.

B.2 ORACLE

It is a database application supported by NetBeans,

Oracle is generally quite similar to MySQL but the difference is

Oracle can be used and connected with NetBeans and must

using drivers to store the data that has been created. Oracle

is one of the several database applications that are commonly used

for connecting to the database in NetBeans because it is relatively easy and fast.

B.3 Microsoft Access

Database Access (Microsoft Access) is a database application

data supported by NetBeans, data can be stored in the format

Microsoft Access, Microsoft Jet Database Engine, Microsoft SQL Server,

Oracle Database, or all database containers that support standard

9
ODBC. Access also supports object-oriented programming techniques.

object.

B.4 MySQL

It is a database application supported by NetBeans.

MySQL has quite a complete feature set, from input, update,

delete and Search. An ODBC interface calls MyODBC which

allows every programming language that supports ODBC to

communicate with a MySQL database. Most of the MySQL source code

in ANSI C.

B.4.1 Some SQL syntax used in NetBeans:

a) Interface :

[Link] Interface used for

sending SQL static reports to the database server and

obtain the result.

[Link] Receives events or

the event that the PooledConnection object is generalized.

b) Classes :

[Link] is a subclass of [Link] used for

SQL DATE data type.

[Link] Class used for

managing a set of JDBC drivers.

c) Exception Classes :

10
[Link] Exception that provides

Information about Database error.

[Link] Exception that provides information

about the Database warning.

C. Advantages and Disadvantages of Netbeans

C.1 Advantages of NetBeans GUI Builder:

One of the advantages of the NetBeans GUI Builder

is FREE. In addition, the NetBeans GUI Builder is very

compatible with Swing as it was directly developed

by Sun, who is primarily a Swing developer.

Disadvantages of NetBeans GUI Builder:

NetBeans only supports one Java GUI development, namely

Swing, which actually has a Java GUI developed by Eclipse.

called SWT and JFace which are quite popular.

2.1.2 Operator

An operator is a symbol used to execute operands.

or it could also be a symbol that functions to operate a piece of equipment. The word

this operand means the value that serves as the input for the operation.

A. Types of Operators in the Java Programming Language

A.1 Arithmetic Operator

Like all programming languages, Java provides

arithmetic operators for manipulating numeric data variables.

11
Operator Usage Description

+ Option1 + Option2 Adding Option 1 with Option 2

- Option1 Subtracting Option 1 from Option 2

* Option1 * Option2 Multiplying Option 1 with Option 2

/ Option1 / Option2 Sharing Option 1 with Option 2

% % Generating the remainder of Option 1 with Option 2

(Table A1: Arithmetic Operators)

A.2 Assignment Operator

Operator assignment in Java is used to assign

an value to a variable. The assignment operator is only '='.

However, in addition to that, Java has several shortcut assignments.

important operations.

Operator Usage Equivalent to

+= Option1 += Option2 Option1 = Option1 + Option 2

-= Option1-=Option2 Option1 = Option1 - Option 2

*= Option1 *= Option2 Option1 = Option1 * Option 2

/= Option1 /= Option2 Option1 = Option1 / Option 2

%= Option1 %= Option2 Option1 = Option1 % Option 2

(Table A2: Assignment Operator)

A.3 Relational Operator

Relational operators in Java are used to produce values.

Boolean is often used to control the flow of a program.

12
Operator Usage Description

== Option1 == Option2 Returns true if Option1 is equal to Option2

!= Option1 != Option2 Returns true if Option1 is not equal to Option2

> Option1 > Option2 Returns true if Option1 is greater than Option2

< Option1 < Option2 Returns true if Option1 is less than Option2

>= Option1 >= Option2 yields true if Option1 is greater than or equal to

with Options

<= Option1 <= Option2 results in true if Option1 is less than or equal to.

with Options2

(Table A3: Relational Operator)

A.4 Logical Operator

This operator is used for logical expressions that produce a value.

Boolean. The operators used are AND ( && ), OR ( || ).

A B A || B A && B

True True True True

True False True False

False True True False

False False False False

(Table A4: Logical Operators)

2.1.3 Class, Object and Method

A class is a collection of objects that share common states and

behavior. A class is used to create objects, and serves as a type

data from objects. Class is a means of encapsulating a collection of data and

a collection of methods that operate on that dataset.

13
Classes also define structure and behavior.

(behavior) an object or a set of objects. Or a class is

a prototype that defines variables and methods in a

General. In Java, there are rules for naming a class. A

Class names must start with an uppercase letter. This is to differentiate.

between class and object. A class is defined with the keyword class. Example

simple from the declaration of a class :

class Student {

String nim; //variable or attribute declaration

String name; //declaration of variables or attributes

An object is an instantiation of a class. If we analogize,

class is a template while object is the item produced from it

template. A class can also be referred to as a category, while an object

is something that meets the criteria that must be fulfilled to enter

in that category. So it can be said that one class can have

many objects, each object has exactly the same characteristics as the

defined in that class. For naming an object,

started with a lowercase letter. The creation of an object for the Mahasiswa class is

as follows:

14
Students students; //object declaration

new Student(); //instantiation of the Student class

Students students = new Students(); //combined into one

Every object has a unique identity, just as every person has.

a unique identity. Example: Students have Student Identification Numbers where a student's identification number is

the student is different from other students.

A method is a part of the code that can be called by


main program or from other methods to run
specific function.
The following are the characteristics of the method:

Must return one value or none at all

2. Several parameters may be accepted as needed or not available.

parameters at all. Parameters can also be referred to as arguments of

function

3. After the method has finished executing, it will return to the method.

who calls him.

General form of the method:

[modifier] return_type methodName(parameter_type) {

methodbody;}

15
2.1.4 Looping and Branching Structure

A. Looping

Looping is a process in programming

that can execute several statements repeatedly

repeat until it stops at a certain condition. The loop essentially

has the function of 'EFFICIENT'.

In Java, loops are divided into 3 types:

For is a loop that has a variable for

performing conditioning. The elements in the for loop are the initial value, the condition, and

addition or subtraction of value

While is a loop that is useful for continuously doing

the loop process continues while the condition is true and stops when

wrong

Do While: is a loop that is almost the same as while,

however, while here functions to process or check the instruction first

first then comparing (conditions). while on

is to check the condition before executing instructions

16
[Link]

Branching is a situation where a statement can be

execute if a condition meets the requirements to work

that statement.

Branching in Java is divided into 2 types:

If The if branching is a branching that involves more

from one condition and the combination of several if and can also be

combine into if - else.

Switch: The switch statement provides a way to handle

many possibilities arise with the way the variable value or

single statement.

2.1.5 Object-Oriented Programming

Object-oriented programming

OOP (Object-Oriented Programming) is a programming paradigm that is oriented towards

to objects. All data and functions in this paradigm are encapsulated.

in classes or objects. Compare with programming logic

structured. Each object can receive messages, process data, and

send a message to other objects,

Object-oriented data models are said to provide flexibility.

easier, program modification, and widely used in engineering

17
large-scale software. Furthermore, OOP supporters claim

that OOP is easier to learn for beginners compared to the approach

Previously, the OOP approach is easier to develop and maintain.

18
CHAPTER III

EXPERIMENT / PRACTICUM RESULTS

3.1 Internship Module 2

In CHAPTER III Results of the Experiment / Practicum Java Programming Language

The author uses the application software Netbeans IDE 8.0.1. Before

In creating this program, the author will show how to

opening / running an application from Netbeans IDE 8.0.1.

1. Click Start > All Programs > Netbeans > Netbeans IDE 8.0.1, after that

click and a display like the following will appear:

(Image 3.1.1: Display of Netbeans 8.0.1)

19
2. Click on the File menu New Project, then select Java from Categories

On the project, select Java Application then click Next

(Image 3.1.2: New Project Display)

3. In the Project Name, fill in the name of the application to be created, for example: Budi

21, then uncheck the checkbox on Create Main Class then click

Finish.

20
(Image 3.1.3: Project Name)

4. Right-click on the Source package > New, then select Java Package

(Figure 3.1.4: creating a package)

21
5. Give the package a name example: 'form' then finish

(Image 3.1.5 : Naming the Package)

6. Next, create a form in the package we created above,

Right click on Package form > New > Select JFrame Form

(Image 3.1.6: Creating a JFrame Form)

22
7. Then name the form in Class Name: Module 2 > Finish

(Image 3.1.7: Naming a Class)

8. Then the Netbeans 8.0.1 worksheet appears for us to create

Design

23
(Figure 3.1.8: Worksheet)

9. Next, create a design like the following using JLabel and JText.

Field and ComboBox and JButton.

(Image 3.1.9: Module 2 Design)

10. After creating the Biodata Variable Design, the next step

what we do is insert the source code into the program that

we want to run.

24
(Image 3.1.10: Source Code of Module 2 program)

11. After the program is typed in, the next step is

compile the program by pressing the F9 key on the keyboard

12. After compiling, the next step is to run the program.

by clicking the menu Run > Run Main Project. Or press Shift+F6

(Image 3.1.11: Program After Being Run)

25
13. Then Enter Data > Then Click the PROCESS button

(Image 3.1.12: Final Result of Module 2)

3.2 Internship Module 3

1. Follow the steps like in module 2 to create a new class named

"Module3" in the "form" Packages. Then design it to look like the following display.

using JLabel, JTextField, JButton

(Image 3.2.1: Module 3 Design)

26
2. Then right-click on the JButton add > Event > Action > actionPerformed.

Do the same one by one for the minus, multiply, and divide JButtons.

3. Then type the following program:

(Image 3.2.2: Source Code btntambah)

(Image 3.2.3: Source Code btnkurang)

(Figure 3.2.4: Source Code btnkali)

(Figure 3.2.5: Source Code btnbagi)

27
4. Then Compile (F9) and Run (Shift+F6) the Program.

(Figure 3.2.6: Program run results)

5. Then input the data you want to enter, for example the first value is 80 and

Enter the second value 90 then click the add button.

(Figure 3.2.7: Final result of Module 3)

3.3 Internship Module 4

1. Follow the steps like module 2 to create a new class named

"Module4" in the "form" Packages. Then design it like the following display:

using JLabel, JTextField, JButton and ComboBox.

28
(Figure 3.3.1: Module 4 Design)

2. Then right-click on the ComboBox Type > Event > Action > actionPerformed

3. Type the following source code.

(Figure 3.3.2: Source code cbojenis)

4. right-click on JButton pay > Event > Action > actionPerformed

5. Type the following source code.

29
(Image 3.3.3: source code pay button)

6. Then Compile (F9) and Run (Shift+F6) the Program.

(Figure 3.3.4: Program run results)

30
7. Then input the data and click the pay button to display

discount (If Member) and total payment.

(Image 3.4.5: Final Result of Module 4)

3.4 Practicum Module 5

1. Follow the steps in module 2 to create a new class named

"Module5" in the Packages "form". Then design it to look like the following display:

using JLabel, JTextField, JButton, ComboBox, Radio Button and

Button Group.

31
(Image 3.4.1: Module 5 Design)

2. Then go to the source tab > type the program

(Figure 3.4.2: Variable Declaration)

32
(Figure 3.4.2: Source of considi determines salary)

(Figure 3.4.3: Source calculating child allowance)

33
(Image 3.4.4: Source calculates the Marriage Option allowance)

(Image 3.4.5: Source Unmarried Options)

(Image 3.4.6: Source Calculating total salary)

34
(Figure 3.4.7: Source deletes on btn Clear)

(Image 3.4.8: Source selects position)

(Figure 3.4.9: Source calls the previous command)

35
3. Then Compile (F9) and Run (Shift+F6) the Program.

(Image 3.4.10: Program Run Results)

4. Then input the data

(Image 3.4.11: Final result of Module 5)

3.5 Internship Module 6

1. Create a new project named 'Module 6' and create a new package with

the name "MDI"

2. Then create a new class named 'MainForm'

36
3. Create a JInternalFrame Form in the MDI Package

4. Right click on MDI Packages > New > JInternalFrame Form

Named "IFModul2" to "IFModul6"

5. Then copy or move Module2 to Module5 from the previous project

into Project 'Module 6' Packages 'MDI' respectively

JInternalFrame Form.

6. Right-click on Module2 > Refactor > Copy > Select project and packages that

Refactor.

7. Open a class named 'FormUtama' then design it to look like the following display:

(Image 3.5.1: Design Module 6)

8. Then go to the source tab, type the following program

(Image 3.5.2: Declaration of global variables that can be accessed by all methods)

37
(Image 3.5.3: Constructor)

(Figure 3.5.4 : Method named NewForm)

9. Then click on the 'File' menu, select 'New' > right-click > event > Action >

actionPerformed.

10. Also do this for the option 'Exit'. Do it one by one.

11. Then type this program

(Image 3.5.5: Source for the options New and Exit)

38
12. Then from the "Data" menu, select Module2 > right click > event > Action >

action performed

13. Also do until Module 5, work on them one by one.

14. After that, type the following program:

(Image 3.5.6: Source for Module 2 and Module 3)

(Image 3.5.7: Source for Module 3 and Module 4)

39
15. Then Compile (F9) and Run (Shift+F6) the Program.

(Figure 3.5.8: Final results of Module 6)

3.6 Internship Module 7

Create a new project named Sales Program

2. Create a new package, right-click on Project > New > Java Packages. Give it a name

connection.

3. Then create a Java Class, right-click on the koneksi package > New > Java Class.

Give the name ClassDB

4. At the bottom of the code public class ClassDB, type the following program:

40
(Image 3.6.1: Source code ClassDB)

5. Create a new Package, right-click on Project, New > Java Package. Name it gui.

6. Create a JFrame Form, right-click on the gui Package, New > JFrame Form. Name it

Form Input Data

7. Then design the display as follows

41
(Image 3.6.2: Module 7 Design)

8. Then type the following program:

(Image 3.6.3: source method readId)

42
(Image 3.6.4: Source method save)

(Figure 3.6.5: Clean source method)

9. Right-click on btnsave > Select event > Action > actionPerformed. Type

the following command code.

(Image 3.6.6: Source btnsave)

43
10. Right-click on btnclear > Select event > Action > actionPerformed. Type

the following command code.

(Image 3.6.7: Source btnclear)

11. Right-click on txtname > Event > Key > KeyTyped. Type the command

the following:

(Image 3.6.8: Source txtnama)

12. Add the MySQL connector library, Method: Right-click on the Libraries folder >

Add Library > Select MySQL JDBC Driver > Add Library

13. Compile and run from the menu Run > Run file or press Shift+F6

(Image 3.6.9: Source Output Module 7)

44
3.7 Internship Module 8

1. Create a new package, right-click on Project > New > Java Package. Give

connectionname, Then Finish.

2. Create a JClass, right-click on the connection Package > New > Java Class. Name it

ClassDB, Then Finish.

3. Add the MySQL connector library, Method: Right-click the Libraries folder >

Add Library > Select MySQL JDBC Driver > Add Library

4. Type the following code at the bottom of the public class ClassDB

(Image 3.7.1: ClassDB source code)

5. Create a new JFrame Form, Right-click on Project > New > JFrame Form. Give

name FormTransaction and name Package gui > Finish

45
Figure 3.7.2: Module 8 Design

6. Class import declaration

(Image 3.7.3: class import declaration)

(Image 3.7.4: Source public formTransaction)

46
(Figure 3.7.5: Source method invoice)

(Image 3.7.6: Source method findId)

47
(Figure 3.7.7: Source method save)

48
(Image 3.7.8: Source payment method)

(Image 3.7.9: Clean source method)

7. Right-click on cbojenis > Select event > Action > actionPerformed, Type

the following program code:

49
(Image 3.7.10: Source cbojenis)

8. Right click on btnbayar > Select event > Action > actionPerformed,

Type the following program code:

(Image 3.7.11: Source btnpay)

9. Right-click on txtnama > Events > Action > MouseClicked, Then type

the following program code:

(Image 3.7.11: Source txtname)

10. Right-click on btnsimpan > Select event > Action > actionPerformed,

Type the following program code:

(Image 3.7.12: Source btnsave)

50
11. Compile and run from the menu Run > Run file or press Shift+F6

(Image 3.7.13: Final result of Module 8)

51
CHAPTER IV

ANALYZE THE RESULTS OF THE EXPERIMENT

4.1 ANALYSIS OF PRACTICUM MODULE 2

The program is used to display the output of Biodata, such as

fill in NPM, Name, Gender, Date of Birth, Address, Hobbies. The palette that

used are jLabel, Text Field, Combo Box, and JButton. jLabel that

used to display the biodata output "variable name" changed individually

becomes lblnpm, lblname, lblgender, lbldate, lbladdress, lblhobby. Then Text

The field used to fill in the data 'variable name' has been changed to txtnpm.

txtname

Because in this Gender type there are 2 options namely: (Male and Female)

The variable name has been changed to cboj k, and the process uses JButton as well.

replace the variable name with btnproses. This is to facilitate in

program writing, Then go back to the design tab and give ActionPerformed

On the Process button, then type the source code as shown in image 3.1.10.

Then run the program.

4.2 ANALYSIS OF PRACTICUM MODULE 3

The program is used to display output results as shown in

Calculator. This program consists of Input First Value, Input Second Value, Result and

Arithmetic Operators such as (+, -, *, /). Here at the First Value Input display,

Input the Second Value and Result using the PaletteText Field used for

52
fill in the first value and the second value, but in the result the writer changes the settings

if the result cannot be edited or deleted, then on the Operator

Arithmetic using PalleteButton allows Arithmetic Operators to be clicked,

such as displaying the results of Addition, Subtraction, Multiplication, and Division.

Change each button to its respective variable name. Then right-click on

button > select Event then MouseClicked and type the command code. Do it.

also on the other button. After that, run the program.

4.3 ANALYSIS OF PRACTICE MODULE 4

This program is used to display output results such as Sales

Items. Below are the details of the items used from the palette:

(Image 4.3.1: item details)

In Price, Discount, and Total Payable there is a setting 'Editable: false' that functions

if it cannot be edited and deleted, the value that appears in that column.

53
4.4 ANALYSIS OF PRACTICUM MODULE 5

The program is used to display output results like a Form

Employee Salary Calculation. Here are the items used:

54
(Figure 4.4.1: item details)

This program also includes the calculation of the Wife Allowance (20% of Basic Salary)

and Child Allowance (15% of Base Salary), as well as displaying the total Salary

Kotor, 10% Tax from Salary, and Net Salary. Radio Button used as an option.

to choose an option (Married and Not Married) because in this display,

the choice of being married or not married determines whether the employee receives

allowance for wife and children.

The program code with awalinta is a variable declared with

the data type Integer as well as the String variable that indicates the type

dataString.

The method named ShowSalary functions to display the amount of salary.

with the statement switchpadatxtgajipokok when the item model is in

I am appointed and chosen

Method named TunjanganAnak functions as a statement

The condition is that child allowances are provided for a maximum of 2 children for each employee.

55
A method named 'marry' is used to express a choice.

option1 jRadioButton1 receives 20% allowance for a wife from salary

stem.

The method named NotMarried is used to determine

The value '0' in child and spouse allowances is also an option choice.

The method named total is a command to display

the net salary in txtgajibersih based on the calculation from txtgajipokok,

wife allowance

The method named BersihTeks functions to clear the value.

on each JText Field with the aim of starting a new value.

4.5 ANALYSIS OF PRACTICUM MODULE 6

The program is used to display output results like the Display

simple website consisting of a Menu Bar such as File, Data, and Help, Method

Create it by clicking the JMenu Bar from the palette and then placing it on the design tab of the form.

File, Data, and Help each have 2 menu items such as (New and Exit), 4

Menu Item that contains (Module 2, Module 3, Module 4, and Module 5), and n 1Menu

Items that contain (About). How to add it Right-click on the Item Menu

Menu bar > Add Form Palette > Menu Item. Then change the text of JMenuItem to

'New' way Right-click JMenuItem1 > Edit Text, Repeat according to

form. Then create a new package named MDI and add

JInternal Frame Form

56
4.6 PRACTICAL ANALYSIS MODULE 7

The program is used to display the output results of Customer Data.

This program consists of Id, Name, Phone Number, and Address with Save and Clear buttons.

Here are the details of the items used:

(Figure 4.6.1: item details)

This Customer Program Form Input Data also connects to MySQL.

Database. In Module 7, this program uses 2 Packages, namely the Gui Package and

Connection Package, this Connection Package connects from the Java Program

Netbeans IDE with MySQL Database. The design of the database and tables is as follows:

57
CREATE DATABASE dbjava;

USE dbjava;

CREATE TABLE tcustomer(id VARCHAR(6) PRIMARY KEY, name VARCHAR

(25), nohp VARCHAR(14), address VARCHAR(100);

In the code section public class ClassDB is the command that connects the results

input into the DATABASE.

The method named 'simpan' is used to save data to the database.

customer.

Then add the MySQL connector library, How to do it: Right-click on the folder

Libraries > Add Library > Select MySQL JDBC Driver > Add Library.

serves as a connector.

4.7 ANALYSIS OF PRACTICUM MODULE 8

The program is used to display output results like

Sales Transaction. This program consists of Invoice Number, Customer Id, Name, Price,

Quantity

Goods, Where the Status of Goods consists of (Silver and Gold), while the Type of Goods

consists of (Choose, iPad, iPhone, and iPod). And the Pay and Save button for

displaying output according to the input. Here are the details of the items used

58
(Image 4.7.1: item details)

In addition, this Sales Transaction program also connects to MySQL.

Database like Module 7. Here is the database design:

CREATE DATABASE dbjava;

USE dbjava;

CREATE TABLE tpenjualan(invoice VARCHAR(12) PRIMARY KEY, date

DATE

59
id VARCHAR(6)

VARCHAR(30)

VARCHAR(12), pay VARCHAR(12)

In Module 8, this program also uses 2 Packages, namely the Gui Package.

and Connection Package, this Connection Package connects from the Program

Java Netbeans IDE with MySQL Database.

Add the MySQL connector library, How to: Right-click the Libraries folder

Add Library > Select MySQL JDBC Driver > Add Library. That works.

as a connector.

In the code section, public class ClassDB is a command that

linking input results to the DATABASE

The method named invoice is used to search the database.

sales

The method named 'bayar' is used to calculate the amount that must be paid.

paid.

The method named clear is used to empty the JText Field.

with the aim of starting a new value.

60
CHAPTER V

CLOSING

CONCLUSION

In this Java Programming practical, I am using Netbeans

IDE 8.0.1 as an editor. From the results of this practical, I can understand and

understand how to design the layout of a form from an application and understand the function of

the source code of each form and connecting them to the database.

SUGGESTION

I hope the Java programming language practicum is improved further. So that

students can build an application or information system that then

can be applied in life as a need for information.

61
REFERENCES

Unable to access the provided URL for translation.

accessed on May 14, 2019

Unable to translate the provided text as it appears to be a URL.

accessed on May 14, 2019

Arga, Muhammad. 2013. Branching and Looping in Programming.

[Link]

[Link], accessed on December 24, 2014

[Link] Example of Class and Object

[Link]

accessed on December 24, 2014

[Link]

accessed on December 28, 2014

62

You might also like