0% found this document useful (0 votes)
40 views3 pages

Tugas Pemrograman Berorientasi Objek: #Application1 (Menggunakan If')

The document discusses two Java programs written by Tasya Indri Agustina Dano, a student in class XI RPL. The first program uses an 'if' statement to check a student's grade based on their score. It takes in a name and score as input, then outputs the grade. The second program uses a 'while' loop to print the iteration number from 0 to 10.

Uploaded by

Tasya
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 views3 pages

Tugas Pemrograman Berorientasi Objek: #Application1 (Menggunakan If')

The document discusses two Java programs written by Tasya Indri Agustina Dano, a student in class XI RPL. The first program uses an 'if' statement to check a student's grade based on their score. It takes in a name and score as input, then outputs the grade. The second program uses a 'while' loop to print the iteration number from 0 to 10.

Uploaded by

Tasya
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/ 3

Nama : Tasya Indri Agustina Dano

Kelas : XI RPL
No. Absen : 33

TUGAS PEMROGRAMAN BERORIENTASI OBJEK

#Application1 (menggunakan ‘if’)


package pertemuan2;

/**
*
* @author USER
*/
import java.util.Scanner;

public class CekGradeNilai {


public static void main(String[] args) {

int nilai;
String nama, grade;

Scanner scan = new Scanner(System.in);

System.out.print("Nama: ");
nama = scan.nextLine();
System.out.print("Nilai: ");
nilai = scan.nextInt();

if ( nilai >= 90 ) {
grade = "A";
} else if ( nilai >= 80 ){
grade = "B+";
} else if ( nilai >= 70 ){
grade = "B";
} else if ( nilai >= 60 ){
grade = "C+";
} else if ( nilai >= 50 ){
grade = "C";
} else if ( nilai >= 40 ){
grade = "D";
} else {
grade = "E";
}

System.out.println("Grade: " + grade);


}
}

Outputnya :
#application2 (menggunakan ‘while’)
package perulangan;

/**
*
* @author USER
*/
public class PerulanganDoWhile {
public static void main(String[] args) {

// membuat variabel
int i = 0;

do {
System.out.println("perulangan ke-" + i);
i++;
} while ( i <= 10);

}
}
Outputnya:

You might also like