Tutorial Programming

Hallo sahabat kali ini ane mau ngebahas , ane dapet test panggilan kerja di luar kota, udah ntu ane di suruh test coding hehehe, terus ane di kasih soal buat lah

program aplikasi kalkulator , bebas pake bahasa pemprograman apa aja? dalam 5 menit hihihihihi , tapi yang di perbolehkan vb, java, php, asp, jsp, pake flowchart jga

boleh, dan pake psedocode boleh juga, nah ane buat pake php, dengan segala genap hati ane, tadaaaa.. jadi dalam 5 menit wkwkwkwkwkkw edisi lebaran tahun 2015 ini

sangat membuat saya takjub, mudah-mudahan ane ke terima yah, amin

berikut coding ny:


<html>
<head>
    <title>FORM METHOD POST</title>
</head>
 <body>
 <form action='calculator.php' method='POST'>
 <table border='0' align='center'> 
  <tr>
   <td>Value 1</td>
   <td>:</td>
   <td><input type='text' name='value_one'></td>
  </tr>
  <tr>
   <td>Value 2</td>
   <td>:</td>
   <td><input type='text' name='value_two'></td>
  </tr>
  <tr>
   <td>Result</td>
   <td>:</td>
   <td>
   <?php
    if (isset($_POST['tambah']) != null){
     if ($_POST['value_one'] == NULL){
      echo "<input type='text' name='result' readonly='' value='Tidak boleh kosong'>";
     }elseif ($_POST['value_two'] == NULL){
      echo "<input type='text' name='result' readonly='' value='Tidak boleh kosong'>";
     }else{
      $a = $_POST['value_one'];
      $b = $_POST['value_two'];
      $result = $a + $b;
      
      echo "<input type='text' name='result' readonly='' value=" . $result . ">";
     }
    }elseif (isset($_POST['kurang']) != null){
     if ($_POST['value_one'] == NULL){
      echo "<input type='text' name='result' readonly='' value='Tidak boleh kosong'>";
     }elseif ($_POST['value_two'] == NULL){
      echo "<input type='text' name='result' readonly='' value='Tidak boleh kosong'>";
     }else{
      $a = $_POST['value_one'];
      $b = $_POST['value_two'];
      $result = $a - $b;
      
      echo "<input type='text' name='result' readonly='' value=" . $result . ">";
     }
    }elseif (isset($_POST['bagi']) != null){
     if ($_POST['value_one'] == NULL){
      echo "<input type='text' name='result' readonly='' value='Tidak boleh kosong'>";
     }elseif ($_POST['value_two'] == NULL){
      echo "<input type='text' name='result' readonly='' value='Tidak boleh kosong'>";
     }else{
      $a = $_POST['value_one'];
      $b = $_POST['value_two'];
      $result = $a / $b;
      
      echo "<input type='text' name='result' readonly='' value=" . $result . ">";
     }
    }elseif (isset($_POST['kali']) != null){
     if ($_POST['value_one'] == NULL){
      echo "<input type='text' name='result' readonly='' value='Tidak boleh kosong'>";
     }elseif ($_POST['value_two'] == NULL){
      echo "<input type='text' name='result' readonly='' value='Tidak boleh kosong'>";
     }else{
      $a = $_POST['value_one'];
      $b = $_POST['value_two'];
      $result = $a * $b;
      
      echo "<input type='text' name='result' readonly='' value=" . $result . ">";
     }
    }else{
     echo "<input type='text' name='result' readonly='' value='null'>";
    }
   ?>
   </td>
  </tr>
  <tr>
   <td><button type='submit' name='tambah'>Tambah +</button></td>
   <td></td>
   <td><button type='submit' name='kurang'>Kurang -</button></td>
  </tr>
  <tr>
   <td><button type='submit' name='bagi'>Bagi /</button></td>
   <td></td>
   <td><button type='submit' name='kali'>Kali *</button></td>
  </tr>
 </table>
 </form>
 </body>
</html>


Sekian tutorial saya semoga bermanfaat. Edisi lebaran penuh hikmah, semoga jadi barokah. amin allahhumma amin ya robbalalamin

No comments:

Post a Comment

Tutorial Programming Designed by Templateism | Ary EJFA Copyright © 2015

Theme images by richcano. Powered by Blogger.