Iklan Tengah Artikel 2

Penerapan statemen kondisi If dan switch dalam java

hpk
Penerapan statemen kondisi If  dan switch dalam java

Pada pertemuan ini, Anda diperkenalkan statemen kendali atau struktur kontrol yang merupakan statemen dalam java yang mengizinkan pengguna untuk memilih proses untuk menjalankan suatu blok kode dan mengabaikan blok kode lainnya. Dalam Java terdapat dua statemen kendali yang dapat digunakan, yaitu If dan Switch. Dua jenis statemen kendali ini akan di praktekkan dalam pertemuan ini.

Tujuan

  1. Memperkenalkan struktur kendali dalam Java.
  2. Membuat program yang di dalamnya terdapat statemen kendali If ataupun Switch.
Penerapan statemen kondisi If 
  • Buat sebuah program java dengan nama praktikum2_1.java dan berikan nama class.
  • Pendeklarasian dan inisialisasi variabel yang akan digunakan 
  •  Berikan kondisi If seperti yang terlihat pada kode program berikut untuk diagnosis penyakit sederhana
  • Dalam kode tersebut terdapat kondisi If bersarang, yang mana di dalam kondisi If terdapat statemen If lagi. Dalam ekspresi logika dapat menggunakan beberapa ekspresi, dengan bantuan penghubung operator logika seperti and (&&), or (||), not(!),dan lainnya.
  • Compile dan run file java yang tersimpan. Jika sesuai dengan kode program yang dicontohkan, maka akan memberikan keluaran "Berikan obat turun panas".
Penerapan statemen kondisi Switch
  1. Buatlah sebuah program java dengan nama praktikum2_2.java dan berikan nama classserta penggunaan package library "java.io".
  2. Lakukan pendeklarasian dan inisialisasi dari variabel yang akan digunakan.
  3. Berikan tampilan menu makanan dan penyimpanan dari pesanan yang dimasukan olehpengguna, menggunakan kode berikut.
  4. dalam baris ke-16 dan ke-19 terdapat fungsi konversi ke tipe data yang digunakan (Integer dan Character), dikarenakan data masukan dari pengguna melalui keyboard akan bertipe String. Selanjutnya masukkan statemen kondisi Switch untuk mendeteksi pilihan menu yang diberikan oleh pengguna, dan untuk menentukan berapa biaya yang harus dibayar.

  5. dalam kode terlihat statemen Switch bersarang seperti pada statemen If pada latihan sebelumnya. Ekspresi logika dalam Switch hanya dapat menerima data dengan tipe Integer dan Character, dan ekspresi logika yang digunakan hanya menerima kondisi persamaan sama dengan (==). Setiap kondisi yang terpenuhi diakhiri dengan break; untuk menandakan akhir dari statemen yang harus dijalankan. Dan terdapat kondisi default: yang akan memberikan keputusan ketika semua kondisi yang diberikan tidak terpenuhi. Compile dan run file java yang tersimpan.



the cheapest car insurance cost of car insurance best car insurance quotes insurance auto insurance quotes car get car insurance quotes online car insurance agent instant car insurance quote car insurance websites direct car insurance insure a car motor car insurance quote cheap car insurance online quotes for car insurance car insurers commercial car insurance motor insurance quote car insurance quotes online get a quote online international health insurance compare car insurance quotes insurance for car compare car insurance car insurance buy life insurance online compare auto insurance international medical insurance general car insurance cheap motor insurance low car insurance car insurance comparison company car insurance budget car insurance private health insurance online quote car insurance cheap motor car insurance car insurance for new drivers cheap car insurance quotes online online car insurance quotes get car insurance quotes car insurance quotes comparison motor car insurance car insurance quotes car insurance cheap comprehensive car insurance best auto insurance short term health insurance motor insurance cheap online car insurance online motor insurance quotes car insurance california buycarinsurance online vehicle insurance free car insurance quotes landlord insurance health insurance for children motorbike insurance monthly car insurance car insurance usa car insurance reviews car insurance renewal quotes vehicle insurance health insurance rates term life insurance quotes vehicle insurance quotes car insurance compare motor vehicle insurance best car insurance motor insurance online quote car insurance online quote life insurance online supplemental health insurance best car insurance rates car insurance discounts motor vehicle insurance quotes auto insurance cheap travel insurance bike insurance travel medical insurance buy car insurance online online motor insurance travel insurance quote get a quote for car insurance health insurance agent car insurance companies cheap car insurance companies travel insurance annual travel insurance commercial vehicle insurance permanent life insurance medical insurance quotes online car insurance cheap car insurance quotes car insurance online quote insurance online level term life insurance health insurance comparison how much is car insurance travel health insurance pet health insurance quotes on cars health ins travel insurance uk quote for car insurance get insurance quote online disability insurance quote temporary health insurance temporary insurance rental car insurance cheap health insurance auto insurance compare third party car insurance buy health insurance auto insurance quotes cheap insurance companies best term life insurance personal health insurance online quote insurance car insurance premium health insurance policies quotes for cars whole life insurance credit insurance cheap van insurance cheap term life insurance cheap motorcycle insurance compare life insurance car insurance cover health insurance motorcycle insurance short term car insurance health insurance coverage insurance qoute cheap life insurance house insurance quote car insurance uk health insurance companies cigna health insurance cheap insurance cheap car insurance uk compare health insurance car insurance for young drivers short term insurance online health insurance caravan insurance life insurance comparison direct insurance health insurance plans motor insurance online car insurance estimator accident insurance home insurance quotes nj car insurance new car insurance private medical insurance home insurance car insurance brokers car insurance rates commercial insurance health insurance quotes motor insurance companies which car insurance car quotes online online auto insurance flood insurance cheap auto insurance quotes car insurance agencies business health insurance term life insurance truck insurance professional indemnity insurance life insurance car insurance policy long term care insurance drive insurance buy insurance car ins motorcycle insurance quote critical illness insurance term insurance student health insurance home insurance comparison insurance rates insurance cover holiday insurance insurance sites online vehicle insurance quotes company website home insurance rates compare insurance buy insurance online affordable medical insurance car insurance coverage product liability insurance home contents insurance buy life insurance renters insurance group health insurance family health insurance motor insurance quote online mortgage insurance best home insurance personal insurance medical insurance property insurance life insurance agent group insurance aetna health insurance cheap medical insurance liability insurance rental insurance life insurance policy group life insurance general liability insurance insurance quotes online all car insurance companies best health insurance insurance plans life insurance for seniors van insurance website quote universal life insurance building insurance co insurance insurance car car insurance prices disability insurance insurance vehicle cheap vehicle insurance senior life insurance medical insurance plans insurance health house insurance life insurance quotes car quotes cheap home insurance

0 Response to "Penerapan statemen kondisi If dan switch dalam java"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel

close
[ klik disini 1X ] [ close ]