W3 - Instruksi Praktikum Teknik Pemrograman Fundamental Programming Structures in Java
W3 - Instruksi Praktikum Teknik Pemrograman Fundamental Programming Structures in Java
_Selamat Mengerjakan_
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.
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.
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.
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
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
Sample Output
berhenti
Sample Input 1
Sample Output 1
jalan
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
………………………………
}
}
{{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 } }