Sebelum mulai coding, pastikan kamu sudah menyiapkan beberapa hal berikut:
- Java Development Kit (JDK): Jika belum terinstall, download dari situs resmi Oracle dan ikuti petunjuk instalasinya.
- Editor atau IDE: Kamu bisa pakai teks editor sederhana seperti Notepad atau editor yang lebih canggih seperti IntelliJ IDEA, Eclipse, atau NetBeans. Untuk pemula, IntelliJ IDEA direkomendasikan karena user-friendly.
- Folder Project: Buat folder baru di komputermu, misalnya
ProjectJava
.
2. Create a New Java File
- Open your chosen editor or IDE.
- Create a new file and name it
Kelulusan.java
. - Save this file in the folder you created (
ProjectJava
).
3. Write the Program Code
You can use the following source code as shown in the image below!
4. Program Code Explanation
- Import Scanner
Function: Importing the
Scanner
class used to read user input.
- Declare Class and Main Method
Function: Declare the
Kelulusan
class and themain
method as the entry point of the program.
- Create a Scanner Object
Function: Create a
scanner
object to take input from the user via the console.
- Request Input Value
Function: Display a message to the user to enter the value, then read that input and store it in the
nilai
variable, which is of type integer.
- Input Validation
Function: Ensure the entered value is within the 0–100 range. If not, the program will display an error message.
- Determine Grade Based on Value
Function: Use the
if-else
structure to determine the grade based on the entered value.Value 71–100: Grade A
Value 61–70: Grade B
Value <=60: Grade C
- Determine Graduation Status
Function: Display the final result consisting of the value, grade, and graduation status.
5. Run the Program
Run Project
To run the program, you can click the button above.
6. Example Program Output
output shows grade A and passed status
output shows grade C and passed status
output shows grade B and failed status
Tips and Tricks
- Input Validation is Crucial!
Always ensure that the input received is as expected. This prevents the program from crashing or producing unwanted results. - Use IDE for Convenience
IDEs like IntelliJ IDEA or Eclipse offer features like auto-complete, debugging, and more, which are extremely helpful, especially for beginners. - Explore Further
Once the basic program works, try adding other features such as:
- Calculating the average of multiple grades.
- Adding more detailed grades (e.g., A+, A, B+, B, etc.).
- Saving results to a file.
Great job! Now you've successfully created a simple grading and graduation program using Java.
Program ini adalah langkah awal yang bagus untuk memahami logika pemrograman dan penggunaan kondisi. Jangan berhenti di sini ya! Coba tambahkan fitur baru atau kembangkan program ini lebih lanjut. Kalau ada pertanyaan atau ide tambahan, jangan ragu untuk berbagi di kolom komentar. Selamat belajar dan happy coding! 😊
Ця програма є чудовим першим кроком для розуміння логіки програмування та використання умовних операторів. Не зупиняйся на цьому! Спробуй додати нові функції або розвинути програму далі. Якщо є питання чи додаткові ідеї, не соромся поділитись ними в коментарях. Успіхів у навчанні та приємного кодування! 😊
Перекладено з: Langkah Membuat Program Penilaian dan Kelulusan Menggunakan Bahasa Java