0% found this document useful (0 votes)
36 views5 pages

Netbeans

The document contains code for two Java programs. The first program collects student data (name, ID, address, test scores) from user input and calculates the student's final grade. It then uses if/else statements to output the grade in letter form based on the score. The second program defines a 2D array to represent a 3x3 grid of seats. It populates the seats with names by prompting the user, and then outputs the filled grid.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views5 pages

Netbeans

The document contains code for two Java programs. The first program collects student data (name, ID, address, test scores) from user input and calculates the student's final grade. It then uses if/else statements to output the grade in letter form based on the score. The second program defines a 2D array to represent a 3x3 grid of seats. It populates the seats with names by prompting the user, and then outputs the filled grid.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Soal 1

package ProgramJavaIF;

import java.util.Scanner;

public class CobaIF2 {

public static void main(String[] args) {

// TODO code application logic here

Scanner input = new Scanner(System.in);

String nama,nim, alamat;

int tugas, mid, uas;

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

nama = input.nextLine();

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

nim = input.nextLine();

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

alamat = input.nextLine();

System.out.print("Masukkan Nilai Tugas : ");

tugas = input.nextInt();

System.out.print("Masukkan Nilai MID : ");

mid = input.nextInt();

System.out.print("Masukkan Nilai UAS : ");

uas = input.nextInt();

double nilaiakhir = (tugas)+(mid)+(uas)/3;

System.out.println("===================================");

System.out.println("DATA MAHASISWA");

System.out.println("===================================");

System.out.println("Nama : " +nama);

System.out.println("NIM: " +nim);

System.out.println("Alamat: " +alamat);


System.out.println("Nilai Tugas : " +tugas);

System.out.println("Nilai MID: " +mid);

System.out.println("Nilai UAS: " +uas);

System.out.println("Total Harga: " +nilaiakhir);

System.out.println("");

if (nilaiakhir >85){

System.out.println("Nilai Huruf = Sangat Memuaskan");

else if (nilaiakhir >75){

System.out.println("Nilai Huruf = Memuaskan");

else if (nilaiakhir >65){

System.out.println("Nilai Huruf = Cukup");

else if (nilaiakhir >55){

System.out.println("Nilai Huruf = Kurang");

else if (nilaiakhir <55){

System.out.println("Nilai Huruf = Gagal");

System.out.println("===================================");

}
Soal 2

import java.util.Scanner;

public class RuangKelas {

public static void main(String[] args) {

// Membuat Array dan Scanner

String[][] meja = new String[3][3];

Scanner scan = new Scanner(System.in);

// mengisi setiap meja

for(int bar = 0; bar < meja.length; bar++){

for(int kol = 0; kol < meja[bar].length; kol++){

System.out.format("Siapa yang akan duduk di meja (%d,%d): ", bar, kol);

meja[bar][kol] = scan.nextLine();

// menampilkan isi Array

System.out.println("-------------------------");

for(int bar = 0; bar < meja.length; bar++){

for(int kol = 0; kol < meja[bar].length; kol++){

System.out.format("| %s | \t", meja[bar][kol]);

System.out.println("");

System.out.println("-------------------------");

You might also like