Cari artikel di situs ini

Tanggapi komentar

bisa kok inputnya berupa integer

Mas. Saya ada info nih kalo input pada java itu bisa langsung berupa integer. Kita harus pake kelas Scanner di programnya. Terlebih dulu kita harus mengimport java.util.Scanner. Untuk memanggil kelas Scannernya kita gunakan nextInt(). Kurang lebih begini programnya import java.util.Scanner; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); int x,y; int hasil; System.out.print("Masukkan bilangan pertama : "); x = sc.nextInt(); System.out.print("Masukkan bilangan kedua : "); y = sc.nextInt(); hasil = x + y; System.out.println("Hasil penjumlahan adalah : " + hasil); } }

Balas

  • Tag HTML yang dibolehkan: <p> <br> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <span> <blockquote> <table> <caption> <tbody> <tr> <td> <h1> <h2> <h3> <h4> <h5> <h6> <address> <pre>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <pre>, <c>, <cpp>, <java>. Beside the tag style "<foo>" it is also possible to use "[foo]".

Informasi lebih lanjut tentang opsi format tulisan

Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated.