0% found this document useful (0 votes)
40 views

W3 - Instruksi Praktikum Teknik Pemrograman Fundamental Programming Structures in Java

The document provides instructions for a programming practical assignment in Java. It contains 7 problems to solve related to programming fundamentals. For each problem, students must provide the source code on GitHub, screenshots of the program output and any issues encountered, and solutions to issues in a report document. The last problem involves adding code to print the output of a 3 dimensional array structure provided in the code snippet.
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)
40 views

W3 - Instruksi Praktikum Teknik Pemrograman Fundamental Programming Structures in Java

The document provides instructions for a programming practical assignment in Java. It contains 7 problems to solve related to programming fundamentals. For each problem, students must provide the source code on GitHub, screenshots of the program output and any issues encountered, and solutions to issues in a report document. The last problem involves adding code to print the output of a 3 dimensional array structure provided in the code snippet.
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
You are on page 1/ 8

W3 - Instruksi Praktikum Teknik Pemrograman

Fundamental Programming Structures in Java

Kerjakan 7 soal dibawah ini dengan mengikuti ketentuan sebagai berikut:


1. Isi sheet monitoring berdasarkan ketentuan yang ada di sheet tersebut.
2. Source code setiap pengerjaan soal, simpan di Github, lampirkan komentar dari hasil
pengerjaan tersebut.
3. Buat laporan hasil pengerjaan berbentuk dokumen, upload laporan di folder Hasil
Praktikum di folder hasil praktikum, laporan harus mencakup:
1. Cover.
2. Persoalan yang telah dikerjakan. Setiap persoalan, harus menjawab beberapa
deskripsi berikut ini:
1. Screenshoot hasil akhir program.
2. Screenshoot setiap jawaban soal yang dipertanyakan.
3. Permasalahan yang dihadapi.
4. Solusi dari permasalahan yang dihadapi.
5. Nama teman yang membantu memecahkan permasalahan di persoalan
ini.

_Selamat Mengerjakan_

W3 - PRAKTIKUM TEKNIK PEMROGRAMAN - 2021 1


Soal 1
Input & Output

Given a string, s, matching the regular expression [A-Za-z !,?._'@]+, split the string into
tokens. We define a token to be one or more consecutive English alphabetic letters. Then, print
the number of tokens, followed by each token on a new line.

Input Format
A single string s.

Constraints
 1  length of s  4.105
 s is composed of any of the following: English alphabetic letters, blank spaces,
exclamation points (!), commas (,), question marks (?), periods (.), underscores (_),
apostrophes ('), and at symbols (@).

Output Format
On the first line, print an integer, n, denoting the number of tokens in string s (they do not
need to be unique). Next, print each of the n tokens on a new line in the same order as they
appear in input string s.

Sample Input:

I wasn't home

Sample Output:

4
I
wasn
t
home

Explanation:
We consider a token to be a contiguous segment of alphabetic characters. There are a total of
4 such tokens in string s, and each token is printed in the same order in which it appears in
string s.

W3 - PRAKTIKUM TEKNIK PEMROGRAMAN - 2021 2


Soal 2
Input & Output (2)

Java's System.out.printf function can be used to print formatted output. The purpose of this
exercise is to test your understanding of formatting output using printf.

To get you started, a portion of the solution is provided for you in the editor; you must format
and print the input to complete the solution.

Input Format
Every line of input will contain a String followed by an integer.
Each String will have a maximum of 10 alphabetic characters, and each integer will be in the
inclusive range from 0 to 999.

Output Format
In each line of output there should be two columns:
 The first column contains the String and is left justified using exactly 15 characters.
 The second column contains the integer, expressed in exactly 3 digits; if the original input
has less than three digits, you must pad your output's leading digits with zeroes.

Sample Input

C 82
python 90
java 100

Sample Output

================================
c 082
python 090
java 100
================================

Explanation
Each String is left-justified with trailing whitespace through the first 15 characters. The
leading digit of the integer is the 16th character, and each integer that was less than 3 digits
now has leading zeroes.

W3 - PRAKTIKUM TEKNIK PEMROGRAMAN - 2021 3


Soal 3
Berhitung

Terdapat 5 buah operator matematika:


1. Penjumlahan, direpresentasikan dengan '+'.
2. Pengurangan, direpresentasikan dengan '-'.
3. Perkalian, direpresentasikan dengan '*'.
4. Pembagian, direpresentasikan dengan '/'.
5. Sisa hasil bagi, direpresentasikan dengan '%'.

Tugas anda adalah menggunakan operator-operator tersebut.

Input Format
Satu baris berisi A, operator, dan B, masing-masing dipisahkan sebuah spasi, yang
menyatakan terdapat operasi "A operator B".

Output Format
Satu baris berisi sebuah bilangan bulat, hasil "A operator B".

Sample Input

1 + 1

Sample Output

Sample Input 1

1000 * 1000

Sample Output 1

1000000

Batasan
• 1 ≤ A, B ≤ 1.000
• Operator dijamin salah satu dari '+', '-', '*', '/', atau '%'.
• Jika operator adalah '/', dijamin A habis dibagi B.

W3 - PRAKTIKUM TEKNIK PEMROGRAMAN - 2021 4


Soal 4
Gaji Agent

Dalam sebuah agent penjualan. Agent akan menerima gaji pokok sebesar Rp.500.000,00
perbulan. Agent akan menerima bonus penjualan sebesar 25% dari total penjualan item jika
berhasil menjual minimal 40 item. Agent akan menerima bonus penjualan 35% dari total
penjualan jika berhasil menjual diatas 80 item. Namun, Jika Agent menjual dibawah 15 item
akan menerima denda pemotongan gajih pokok sebesar 15% dari total minus penjualan ke 15
item. Selain itu agen hanya menerima bonus 10% setiap itemnya. Harga setiap item adalah Rp.
50.000,00

Input Format
Satu baris berupa jumlah penjualan bulan ini.

Output Format
Satu baris berisi sebuah bilangan berupa gajih yang diterima.

Sample Input

35

Sample Output

675000

Sample Input 1

14

Sample Output 1

492500

W3 - PRAKTIKUM TEKNIK PEMROGRAMAN - 2021 5


Soal 5
Buka Tutup Jalan

Buka tutup jalan merupakan hal yang lumrah ada di pengaturan jalan khususnya di Indonesia.
Buka tutup jalan kali ini memiliki aturan yang disempurnakan. Setiap empat mobil yang lewat
digabung setiap angkanya. Jika (gabungan angka tersebut dikurangi 999999) hasilnya dibagi 5
sisa bagi hasilnya 0 maka 4 mobil tersebut harus berhenti, dan memperbolehkan mobil lainnya
dari arah bersebrangan untuk jalan. Begitu terus sebaliknya.

Input Format
Satu baris berupa plat number untuk 4 mobil

Output Format
Berupa tulisan “Jalan” atau “Berhenti

Sample Input

3555 2333 4555 6660

Sample Output

berhenti

Sample Input 1

1223 1111 2222 4449

Sample Output 1

jalan

W3 - PRAKTIKUM TEKNIK PEMROGRAMAN - 2021 6


Soal 6
Big Number

In this problem, you have to add and multiply huge numbers! These numbers are so big that
you can't contain them in any ordinary data types like a long integer.

Use the power of Java's BigInteger class and solve this problem.

Input Format
There will be two lines containing two numbers, a and b.

Constrains
a and b are non-negative integers and can have maximum 200 digits.

Output Format
Output two lines. The first line should contain a + b, and the second line should contain a x b.
Don't print any leading zeros.

Sample Input

2345
35

Sample Output

2380
82075

Explanation

2345 + 35 = 2380
2345 x 35 = 82075

W3 - PRAKTIKUM TEKNIK PEMROGRAMAN - 2021 7


Soal 7
Array

Diketahui syntaks program seperti dibawah ini:

public class MDArrayJava


{
public static void main(String[] args)
{
//One Dimensional Arrays
int[] fisrtArray = {2, 5, 3};
int[] secondArray = {9, 5, 3};
int[] thirdArray = {2, 4, 9};
int[] fourthArray = {10, 11, 12};
int[] fifthArray = {13, 14, 15};
int[] sixthArray = {16, 17, 18};
int[] seventhArray = {19, 20, 21};
int[] eighthArray = {22, 23, 24};
int[] ninthArray = {25, 26, 27};

//Two Dimensional Arrays


int[][] twoDimensionalArray1 = {fisrtArray, secondArray,
thirdArray};

int[][] twoDimensionalArray2 = {fourthArray, fifthArray,


sixthArray};

int[][] twoDimensionalArray3 = {seventhArray, eighthArray,


ninthArray};

//Three Dimensional Array


int[][][] threeDimensionalArray = {twoDimensionalArray1,
twoDimensionalArray2, twoDimensionalArray3};

………………………………
}
}

Tambahkan kode agar output yang dihasilkan adalah sebagai berikut :

{{2 5 3 } {9 5 3 } {2 4 9 } }
{{10 11 12 } {13 14 15 } {16 17 18 } }
{{19 20 21 } {22 23 24 } {25 26 27 } }

W3 - PRAKTIKUM TEKNIK PEMROGRAMAN - 2021 8

You might also like