Select Language



Followers

IT Programmer. Powered by Blogger.

30 July 2010

Contoh IF Bersarang (Nested IF) dalam Java

"Om Swastiastu"

Pernyataan IF bisa berada dalam pernyataan IF. Kondisi seperti ini sering disebut sebagai IF bersarang atau nested IF. Contoh IF bersarang atau nested for dalam Java dapat kalian lihat pada contoh program dibawah ini.


import java.util.*;

public class NestedIF
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int nilai;

System.out.print("Masukkan nilai ujian [ 0 - 100 ]: ");
nilai = input.nextInt();

if(nilai >=90 && nilai <=100)
System.out.println("Nilai ujian = A");
else if(nilai >=80 && nilai <=89)
System.out.println("Nilai ujian = B");
else if(nilai>=60 && nilai <=79)
System.out.println("Nilai ujian = C");
else if(nilai >= 50 && nilai <=59)
System.out.println("Nilai ujian = D");
else
System.out.println("Nilai ujian = E");
}
}


"Om Santhi, Santhi, Santhi, Om"



Comments:

Ada 1
Hasanaji said...
pada hari 

Sipp bisa di coba, thank...

Social Media


Facebook Page

Traffic

feeds  Powered by  MyPagerank.Net PR Programming Blogs - Blog Catalog Blog Directory    Yahoo bot last visit powered by MyPagerank.Net bl srvce Y! Msn bot last visit powered by MyPagerank.Net Add to Google Reader or Homepage  backlink-clever  Programming Blogs - BlogCatalog Blog Directory

Programming Tutorial


Info


Tips
Downloads
Friends
Sponsor
Visitor
 
This Blog is proudly powered by Blogger.com | Template by Bali Web Development | Privacy Policy | Rise Up!!