Anda di halaman 1dari 7

BINUS University

BINUS ONLINE LEARNING Semester: Odd / Even *)


Period: 1 / 2 *)
 Graduate Program  Undergraduate Program
Academic Year:
 Final Exam  Others Exam:
2021/2022
Faculty / Dept. : Binus Online Learning/Computer Science
Course : COMP6727037 - Introduction to Student ID : 2502048514
Programming
Day/ Date : Senin – Senin / 15 – 22 Agustus 2022
BULC : Bandung, Bekasi, Jakarta, Malang, Palembang, N a m e : M. Rivaldi Sudrajat
Semarang
Class : BKDA, TKDA
Time : 00.00 – 12.00 WIB
Signature :
Exam Feature : Open/ Close Books*)
Equipment : Exam Booklet / Calculator / Laptop )
) Strikethrough the unnecessary items
Please insert this test paper into the exam booklet and submit both documents after the test!!!
The penalty for CHEATING is DROP OUT!!!
PETUNJUK UJIAN
i. Jawablah setiap pertanyaan yang berada pada bagian PERTANYAAN UJIAN dibawah ini
ii. Jawaban di ketik rapi pada halaman JAWABAN UJIAN dibawah ini
iii. Jawaban dikumpulkan paling lambat tanggal 22 Agustus 2022 dalam bentuk file dan submit melalui portal ujian
iv. Format file Jawaban adalah : KodeMatakuliah-Nama Matakuliah-NIM.pdf
Contoh : COMP6727037 - Introduction to Programming - 2012345678.pdf

PERTANYAAN UJIAN

No. Deskripsi Soal Bobot


Buatlah sebuah design class dengan kriteria sebagai berikut :
1 35
a. Class digunakan untuk menyimpan data mahasiswa
b. nasabah memiliki data berupa nim, nama dan nilai
c. terdapat fungsi untuk ubah nilai, dimana fungsi ini berguna untuk merubah nilai.
Validasikan nilai hanya bisa antara 0 dan 100
d. terdapat fungsi untuk melihat data mahasiswa dimana fungsi ini berguna untuk
menampilkan data nasabah seperti nim, nama dan nilai.
Buatlah juga void mainnya untuk memberikan contoh penggunaan class yang sudah
dibuat
2 Buatlah sebuah fungsi sorting, dimana fungsi ini dapat dgunakan untuk mensorting 45
data banyak mahasiswa ( nim, nama dan nilai ). Data tersebut disorting berdasarkan
nama secara ascending ( dari a ke z ).
Buat juga void mainnya dengan ketentuan sbagai berikut :
a. Program akan meminta input sebuah angka n yang mewakili jumlah data yang
mau diinput
b. Program akan meminta input data berupa nim, nama dan nilai sebanyak n yang
diinput pada point a. validasikan
i. nim tidak boleh ada yang sama
ii. nilai harus di antara 0 dan 100
c. Program akan menampilkan data dalam bentuk tersorting ascending berdasarkan
nama mahasiswa
Contoh :
input jumlah data : 4

masukkan data ke 1 :
nim : 1234
nama : tono
nilai : 90
masukkan data ke 2 :
nim : 1235
No. Deskripsi Soal Bobot
nama : andi
nilai : 80
masukkan data ke 3 :
nim : 1236
nama : budi
nilai : 65
masukkan data ke 4 :
nim : 1237
nama : abby
nilai : 77

result :
1. 1237 abby 77
2. 1235 andi 80
3. 1236 budi 65
4. 1234 tono 90

Buatlah sebuah program untuk mencetak deret angka dengan ketentuan sebagai
3 20
berikut:
a. program meminta 2 input.
b. Input pertama mewakili jumlah angka yang mau dicetak
c. Input kedua mewakili batas angka yang dicetak
d. Resultnya angka akan dicetak mulai dari batas yang diinput dan terus dikurang 1.
Jika angka sudah mencapai angka 1, maka angka akan dimulai lagi dari batas
yang diinput
Contoh1 :
Input jumlah angka : 5
input batas angka : 3
output : 3 2 1 3 2

Contoh2 :
Input jumlah angka : 10
input batas angka : 4
output : 4 3 2 1 4 3 2 1 4 3
RUBRIK PENILAIAN
LO SKORE : % dari Bobot NILAI
Bobot KONTEN / ELEMEN
(85 <= 100) (75 <= 84) (65 <= 74) (<= 64) Skor x bobot
Level
Pseudo Code, Pseudo Code, Pseudo Code, Pseudo Code,
Use pseudocode,
LO1 Flowchart, or NS Flowchart, or NS Flowchart, or NS Flowchart, or NS
Flowchart, or NS
Understanding Diagram are Diagram are Diagram are Diagram are
Diagram to explain
10 relevant to express relevant to express relevant to express relevant to express
Algorithm
the algorithm the algorithm the algorithm the algorithm
Use Java syntax to Java syntax is used Java syntax is used Java syntax is used Java syntax for the
perform different kinds appropriately, and appropriately, but appropriately but algorithm is used
LO1
of algorithms Java the algorithm is not all the the algorithm is not inappropriately, and
Understanding
syntax is used suitable algorithm is suitable suitable not suitable with
10
appropriately, and the the algorithm
algorithm is suitable
All of the More than half of The operations is The operations is
LO2 Ability to express operations are the operations are expressed for expressed wrongly
Understanding arithmetic assignment, expressed properly expressed properly different purpose
30 logical, and relatonal

Java application is Java application is Java application is Java application is


LO3 Apply the right built perfectly and built, but not built not built
Apply algorithms to solve relevant to the relevant to the inappropriately
50 problem Using JAVA algorithm algorithm

TOTAL NILAI UJIAN


JAWABAN UJIAN
1. Code:

public class data {


String name;
long nim;
int score;
public static void print (data input){
System.out.println("Data Mahasiswa\n"
+ "Nama : "+input.name+"\n"
+ "NIM : "+input.nim+"\n"
+ "Nilai : "+input.score+"\n"
);
}
}

public class Mahasiswa {

public static void main(String[] args) {


Scanner scan = new Scanner(System.in);
data input = new data();

System.out.print("Masukkan Nama : ");


input.name= scan.nextLine();
System.out.println();

System.out.print("Masukkan NIM : ");


input.nim = scan.nextLong();
System.out.println();
scan.nextLine();
do {System.out.print("Masukkan Nilai (0-100) : ");
input.score = scan.nextInt();
}while (input.score<0||input.score>100);
System.out.println();
scan.nextLine();

data.print(input);

2. Code:

import java.util.Comparator;

public class student {


String name;
int nim;
int score;

student(String name, int nim, int score){


this.name=name;
this.nim=nim;
this.score=score;
}

public String getName() {


return name;
}

public String print(){


return nim+" "+name+" "+score;
}

public static Comparator<student> studentnamecomparator = new Comparator


<student>() {
public int compare (student student1, student student2) {
String name1 = student1.getName().toUpperCase();
String name2 = student2.getName().toUpperCase();

return name1.compareToIgnoreCase(name2);
}
};
}

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;

public class no2 {

public static void main(String[] args) {


Scanner scan=new Scanner(System.in);

int quota;
System.out.print("Input Jumlah Data : ");
quota=scan.nextInt();

String name ;
int nim ;
int score ;
student[] stdlist = new student [quota];
ArrayList<String> names = new ArrayList<String>();

for (int i=0; i<quota; i++) {


int no =1;
System.out.println("\nMasukkan Data ke "+ (no+i) +" : ");

System.out.print("NIM \t: ");


nim=scan.nextInt();
scan.nextLine();

do {
System.out.print("Nama \t: ");
name=scan.nextLine();
}while (names.contains(name));
names.add(name);

do {
System.out.print("Nilai \t: ");
score=scan.nextInt();
}while (score<1||score>100);

stdlist[i] = new student (name, nim, score);


}

System.out.println("\nHasil : ");
Arrays.sort(stdlist, student.studentnamecomparator);
for(int i =0; i< stdlist.length;++i){
int no =1;
System.out.println(no+i+"."+stdlist[i].print());
}

3. Code:

import java.util.Scanner;
public class No3 {

public static void main(String[] args) {


Scanner scan = new Scanner(System.in);
int amount;
int limit;

System.out.print("Input Jumlah Angka : ");


amount=scan.nextInt();
System.out.print("Input Batas Angka : ");
limit=scan.nextInt();

System.out.println("Output : ");

int reset = 0- limit;

for (int i=0; i<amount; i++) {


System.out.print(limit+" ");
limit --;
if (limit==0) {limit=reset*-1;}
}

Anda mungkin juga menyukai