/**
* Title : Program test penyeleksian kondisi If
* Deskripsi: Menggunakan If untuk menyeleksi nilai ujian
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class DemoIf {
/** Main Method */
public static void main(String[] args) throws IOException {
double nilaiInput;
System.out.println("\nPROGRAM DEMO IF");
System.out.println("-----------------\n");
// Menginstruksikan user untuk menginputkan nilai
System.out.print("Masukkan nilai [0 - 100]: ");
nilaiInput = InputConsole.readDouble();
// Menyeleksi kondisi dan mencetak hasil ke console
if (nilaiInput >= 60)
System.out.println("\nSelamat, anda lulus mata kuliah ini.");
}
}
class InputConsole {
public static double readDouble() throws IOException{
int nilai;
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
String number = bufferedreader.readLine();
nilai = Integer.parseInt(number);
return nilai;
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment