Selasa, 16 Oktober 2018

PWEB C- UTS

Pada kesempatan kali ini saya ditugaskan membuat web untuk menginput daftar prestasi siswa dengan php dan mysql. Berikut adalah hasilnya:
1.home
2. formulir
3. list prestasi

Berikut saya lampirkan pula ´source codenya:
1. config.php

 <?php  
 $server = "localhost";  
 $user = "root";  
 $password = "";  
 $nama_database = "prestasi";  
 $db = mysqli_connect($server, $user, $password , $nama_database);  
 if( !$db ){  
   die("Gagal terhubung dengan database: " . mysqli_connect_error());  
 }  
 ?>  
2. form_daftar.php

<!DOCTYPE html>  
 <html>  
 <head>  
   <title>Formulir Prestasi Siswa Kelas 9A | SMA SKJ</title>  
 </head>  
 <body>  
   <header>  
     <h3>Formulir Prestasi Siswa Kelas 9A</h3>  
   </header>  
   <form action="proses_daftar.php" method="POST">  
     <fieldset>  
       <input type="hidden" name="id" value="<?php echo $siswa['id'] ?>" />  
     <p>  
       <label for="Nama">Nama: </label>  
       <input type="text" name="Nama" value="<?php echo $siswa['Nama'] ?>" />  
     </p>  
     <p>  
       <label for="NIS">NIS: </label>  
       <input type="text" name="NIS" value="<?php echo $siswa['NIS'] ?>" />  
     </p>  
     <p>  
       <label for="Bidang">Bidang Prestasi: </label>
        <input type="text" name="Bidang" value="<?php echo $siswa['Bidang'] ?>" />       
       </p>  
     <p>  
       <label for="Prestasi">Prestasi: </label>  
       <textarea name="Prestasi"><?php echo $siswa['Prestasi'] ?></textarea>  
     </p>  
     <p>  
       <input type="submit" value="Simpan" name="simpan" />  
     </p>  
     </fieldset>  
   </form>  
   </body>  
 </html>  
3. form_edit.php

<?php  
 include("config.php");   
 if( !isset($_GET['id']) ){  
   header('Location: list_siswa.php');  
 }  
 $id = $_GET['id'];  
 $sql = "SELECT * FROM prestasi WHERE id=$id";  
 $query = mysqli_query($db, $sql);  
 $siswa = mysqli_fetch_assoc($query);  
 if( mysqli_num_rows($query) < 1 ){  
   die("data tidak ditemukan...");  
 }  
 ?>  
 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>Formulir Perubahan Prestasi Siswa Kelas 9A | SMA SKJ</title>  
 </head>  
 <body>  
   <header>  
     <h3>Formulir Perubahan Prestasi Siswa</h3>  
   </header>  
   <form action="proses_edit.php" method="POST">  
     <fieldset>  
       <input type="hidden" name="id" value="<?php echo $siswa['id'] ?>" />  
     <p>  
       <label for="Nama">Nama: </label>  
       <input type="text" name="Nama" placeholder="nama lengkap" value="<?php echo $siswa['nama'] ?>" />  
     </p>  
     <p>  
       <label for="NIS">NIS: </label>  
       <textarea name="NIS"><?php echo $siswa['nis'] ?></textarea>  
     </p>  
     <p>  
       <label for="Bidang">Bidang Prestasi: </label>  
       <?php $jk = $siswa['Bidang']; ?>  
       <label><input type="radio" name="Bidang" value="Akademik" <?php echo ($Bidang == 'Akademik') ? "checked": "" ?>> Akademik</label>  
       <label><input type="radio" name="Bidang" value="non-Akademik" <?php echo ($Bidang == 'non-Akademik') ? "checked": "" ?>> non-Akademik</label>  
     </p>  
     <p>  
       <label for="Prestasi">Prestasi: </label>  
       <input type="text" name="Prestasi" placeholder="Prestasi" value="<?php echo $siswa['Prestasi'] ?>" />  
     </p>  
     <p>  
       <input type="submit" value="Simpan" name="simpan" />  
     </p>  
     </fieldset>  
   </form>  
   </body>  
 </html>  
4. hapus.php

<?php  
 include("config.php");  
 if( isset($_GET['id']) ){  
   $id = $_GET['id'];  
   $sql = "DELETE FROM prestasi WHERE id=$id";  
   $query = mysqli_query($db, $sql);  
   if( $query ){  
     header('Location: list_siswa.php');  
   } else {  
     die("gagal menghapus...");  
   }  
 } else {  
   die("akses dilarang...");  
 }  
 ?>  
5. index.php

<!DOCTYPE html>  
 <html>  
 <head>  
   <title>Data Siswa Berprestasi SMA SKJ</title>  
 </head>  
 <body>  
   <header>  
     <h3>Daftar Siswa Berprestasi</h3>  
     <h1>Kelas 9A</h1>  
   </header>  
   <h4>Menu</h4>  
   <nav>  
     <ul>  
       <li><a href="form_daftar.php">Input Prestasi Siswa</a></li>  
       <li><a href="list_siswa.php">List Prestasi</a></li>  
     </ul>  
   </nav>  
 <?php if(isset($_GET['status'])): ?>  
   <p>  
     <?php  
       if($_GET['status'] == 'sukses'){  
         echo "Input prestasi siswa berhasil!";  
       } else {  
         echo "Penginputan gagal!";  
       }  
     ?>  
   </p>  
 <?php endif; ?>  
   </body>  
 </html>  
6. list_siswa.php

<?php include("config.php"); ?>  
 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>Pendaftaran Siswa Baru | SMK Coding</title>  
 </head>  
 <body>  
   <header>  
     <h3>Siswa yang berprestasi</h3>  
   </header>  
   <nav>  
     <a href="form_daftar.php">[+] Tambah Baru</a>  
   </nav>  
   <br>  
   <table border="1">  
   <thead>  
     <tr>  
       <th>No</th>  
       <th>Nama</th>  
       <th>NIS</th>  
       <th>Bidang Prestasi</th>  
       <th>Prestasu</th>  
       <th>Tindakan</th>  
     </tr>  
   </thead>  
   <tbody>  
     <?php  
     $sql = "SELECT * FROM prestasi";  
     $query = mysqli_query($db, $sql);  
     while($siswa = mysqli_fetch_array($query)){  
       echo "<tr>";  
       echo "<td>".$siswa['id']."</td>";  
       echo "<td>".$siswa['Nama']."</td>";  
       echo "<td>".$siswa['NIS']."</td>";  
       echo "<td>".$siswa['Bidang']."</td>";  
       echo "<td>".$siswa['Prestasi']."</td>";  
       echo "<td>";  
       echo "<a href='form edit.php?id=".$siswa['id']."'>Edit</a> | ";  
       echo "<a href='hapus.php?id=".$siswa['id']."'>Hapus</a>";  
       echo "</td>";  
       echo "</tr>";  
     }  
     ?>  
   </tbody>  
   </table>  
   <p>Total: <?php echo mysqli_num_rows($query) ?></p>  
   </body>  
 </html>  
7. proses_daftar.php

 <?php  
 include("config.php");  
 if(isset($_POST['simpan'])){  
  $id = $_POST['id'];  
   $Nama = $_POST['Nama'];  
   $NIS = $_POST['NIS'];  
   $Bidang = $_POST['Bidang'];  
   $Prestasi = $_POST['Prestasi'];  
   $sql = "UPDATE prestasi nama='$Nama', NIS='$NIS', Bidang='$Bidang', Prestasi='$Prestasi', WHERE id=$id";  
   $query = mysqli_query($db, $sql);  
   if( $query ) {  
     header('Location: index.php?status=sukses');  
   } else {  
     header('Location: index.php?status=gagal');  
   }  
 } else {  
   die("Akses dilarang...");  
 }  
 ?>  
8. proses_edit.php

<?php  
 include("config.php");  
 if(isset($_POST['simpan'])){  
   $id = $_POST['id'];  
   $Nama = $_POST['Nama'];  
   $NIS = $_POST['NIS'];  
   $Bidang = $_POST['Bidang'];  
   $Prestasi = $_POST['Prestasi'];  
   $sql = "UPDATE prestasi nama='$Nama', NIS='$NIS', Bidang='$Bidang', Prestasi='$Prestasi', WHERE id=$id";  
   $query = mysqli_query($db, $sql); 
   if( $query ) {  
     header('Location: list siswa.php');  
   } else {  
     die("Gagal menyimpan perubahan...");  
   }  
 } else {  
   die("Akses dilarang...");  
 }  
 ?>  

PWEB C formulir pendaftaran siswa

pada kesempatan kali ini saya mendapatkan tugas membuat formulir pendaftaran siswa dengan menggunakan php dan mysql. berikut adalah hasilnya:



berikut saya lampirkan pula source codenya:
1. config.php

  <?php   
  $server = "localhost";   
  $user = "root";   
  $password = "";   
  $nama_database = "pendaftaran_siswa";   
  $db = mysqli_connect($server, $user, $password , $nama_database);   
  if( !$db ){   
   die("Gagal terhubung dengan database: " . mysqli_connect_error());   
  }   
  ?>   
2. form daftar.php

 <!DOCTYPE html>   
  <html>   
  <head>   
   <title>Formulir Pendaftaran Siswa Baru | SMK Coding</title>   
  </head>   
  <body>   
   <header>   
    <h3>Formulir Pendaftaran Siswa Baru</h3>   
   </header>   
   <form action="proses-pendaftaran.php" method="POST">   
    <fieldset>   
    <p>   
     <label for="nama">Nama: </label>   
     <input type="text" name="nama" placeholder="nama lengkap" />   
    </p>   
    <p>   
     <label for="alamat">Alamat: </label>   
     <textarea name="alamat"></textarea>   
    </p>   
    <p>   
     <label for="jenis_kelamin">Jenis Kelamin: </label>   
     <label><input type="radio" name="jenis_kelamin" value="laki-laki"> Laki-laki</label>   
     <label><input type="radio" name="jenis_kelamin" value="perempuan"> Perempuan</label>   
    </p>   
    <p>   
     <label for="agama">Agama: </label>   
     <select name="agama">   
      <option>Islam</option>   
      <option>Kristen</option>   
      <option>Hindu</option>   
      <option>Budha</option>   
      <option>Katolik</option>   
     </select>   
    </p>   
    <p>   
     <label for="sekolah_asal">Sekolah Asal: </label>   
     <input type="text" name="sekolah_asal" placeholder="nama sekolah" />   
    </p>   
    <p>   
     <input type="submit" value="Daftar" name="daftar" />   
    </p>   
    </fieldset>   
   </form>   
   </body>   
  </html>   
3.form edit.php

 <?php   
  include("config.php");   
  // kalau tidak ada id di query string   
  if( !isset($_GET['id']) ){   
   header('Location: list-siswa.php');   
  }   
  //ambil id dari query string   
  $id = $_GET['id'];   
  // buat query untuk ambil data dari database   
  $sql = "SELECT * FROM calon_siswa WHERE id=$id";   
  $query = mysqli_query($db, $sql);   
  $siswa = mysqli_fetch_assoc($query);   
  // jika data yang di-edit tidak ditemukan   
  if( mysqli_num_rows($query) < 1 ){   
   die("data tidak ditemukan...");   
  }   
  ?>   
  <!DOCTYPE html>   
  <html>   
  <head>   
   <title>Formulir Edit Siswa | SMK Coding</title>   
  </head>   
  <body>   
   <header>   
    <h3>Formulir Edit Siswa</h3>   
   </header>   
   <form action="proses-edit.php" method="POST">   
    <fieldset>   
     <input type="hidden" name="id" value="<?php echo $siswa['id'] ?>" />   
    <p>   
     <label for="nama">Nama: </label>   
     <input type="text" name="nama" placeholder="nama lengkap" value="<?php echo $siswa['nama'] ?>" />   
    </p>   
    <p>   
     <label for="alamat">Alamat: </label>   
     <textarea name="alamat"><?php echo $siswa['alamat'] ?></textarea>   
    </p>   
    <p>   
     <label for="jenis_kelamin">Jenis Kelamin: </label>   
     <?php $jk = $siswa['jenis_kelamin']; ?>   
     <label><input type="radio" name="jenis_kelamin" value="laki-laki" <?php echo ($jk == 'laki-laki') ? "checked": "" ?>> Laki-laki</label>   
     <label><input type="radio" name="jenis_kelamin" value="perempuan" <?php echo ($jk == 'perempuan') ? "checked": "" ?>> Perempuan</label>   
    </p>   
    <p>   
     <label for="agama">Agama: </label>   
     <?php $agama = $siswa['agama']; ?>   
     <select name="agama">   
      <option <?php echo ($agama == 'Islam') ? "selected": "" ?>>Islam</option>   
      <option <?php echo ($agama == 'Kristen') ? "selected": "" ?>>Kristen</option>   
      <option <?php echo ($agama == 'Hindu') ? "selected": "" ?>>Hindu</option>   
      <option <?php echo ($agama == 'Budha') ? "selected": "" ?>>Budha</option>   
      <option <?php echo ($agama == 'Katolik') ? "selected": "" ?>>Katolik</option>   
     </select>   
    </p>   
    <p>   
     <label for="sekolah_asal">Sekolah Asal: </label>   
     <input type="text" name="sekolah_asal" placeholder="nama sekolah" value="<?php echo $siswa['sekolah_asal'] ?>" />   
    </p>   
    <p>   
     <input type="submit" value="Simpan" name="simpan" />   
    </p>   
    </fieldset>   
   </form>   
   </body>   
  </html>   
4. hapus.php

 <?php   
  include("config.php");   
  if( isset($_GET['id']) ){    
   $id = $_GET['id'];   
   $sql = "DELETE FROM calon_siswa WHERE id=$id";   
   $query = mysqli_query($db, $sql);  
   if( $query ){   
    header('Location: list-siswa.php');   
   } else {   
    die("gagal menghapus...");   
   }   
  } else {   
   die("akses dilarang...");   
  }   
  ?>   
5. index.php

 <!DOCTYPE html>   
  <html>   
  <head>   
   <title>Pendaftaran Siswa Baru | SMK Coding</title>   
  </head>   
  <body>   
   <header>   
    <h3>Pendaftaran Siswa Baru</h3>   
    <h1>SMK Coding</h1>   
   </header>   
   <h4>Menu</h4>   
   <nav>   
    <ul>   
     <li><a href="form-daftar.php">Daftar Baru</a></li>   
     <li><a href="list-siswa.php">Pendaftar</a></li>   
    </ul>   
   </nav>   
  <?php if(isset($_GET['status'])): ?>   
   <p>   
    <?php   
     if($_GET['status'] == 'sukses'){   
      echo "Pendaftaran siswa baru berhasil!";   
     } else {   
      echo "Pendaftaran gagal!";   
     }   
    ?>   
   </p>   
  <?php endif; ?>   
   </body>   
  </html>   
6. list siswa.php

 <?php include("config.php"); ?>   
  <!DOCTYPE html>   
  <html>   
  <head>   
   <title>Pendaftaran Siswa Baru | SMK Coding</title>   
  </head>   
  <body>   
   <header>   
    <h3>Siswa yang sudah mendaftar</h3>   
   </header>   
   <nav>   
    <a href="form-daftar.php">[+] Tambah Baru</a>   
   </nav>   
   <br>   
   <table border="1">   
   <thead>   
    <tr>   
     <th>No</th>   
     <th>Nama</th>   
     <th>Alamat</th>   
     <th>Jenis Kelamin</th>   
     <th>Agama</th>   
     <th>Sekolah Asal</th>   
     <th>Tindakan</th>   
    </tr>   
   </thead>   
   <tbody>   
    <?php   
    $sql = "SELECT * FROM calon_siswa";   
    $query = mysqli_query($db, $sql);   
    while($siswa = mysqli_fetch_array($query)){   
     echo "<tr>";   
     echo "<td>".$siswa['id']."</td>";   
     echo "<td>".$siswa['nama']."</td>";   
     echo "<td>".$siswa['alamat']."</td>";   
     echo "<td>".$siswa['jenis_kelamin']."</td>";   
     echo "<td>".$siswa['agama']."</td>";   
     echo "<td>".$siswa['sekolah_asal']."</td>";   
     echo "<td>";   
     echo "<a href='form-edit.php?id=".$siswa['id']."'>Edit</a> | ";   
     echo "<a href='hapus.php?id=".$siswa['id']."'>Hapus</a>";   
     echo "</td>";   
     echo "</tr>";   
    }   
    ?>   
   </tbody>   
   </table>   
   <p>Total: <?php echo mysqli_num_rows($query) ?></p>   
   </body>   
  </html>   
7. proses daftar.php

 <?php   
  include("config.php");   
  if(isset($_POST['simpan'])){   
   $id = $_POST['id'];   
   $nama = $_POST['nama'];   
   $alamat = $_POST['alamat'];   
   $jk = $_POST['jenis_kelamin'];   
   $agama = $_POST['agama'];   
   $sekolah = $_POST['sekolah_asal'];  
   $sql = "UPDATE calon_siswa SET nama='$nama', alamat='$alamat', jenis_kelamin='$jk', agama='$agama', sekolah_asal='$sekolah' WHERE id=$id";   
   $query = mysqli_query($db, $sql);   
   if( $query ) {   
    header('Location: list-siswa.php');   
   } else {   
    die("Gagal menyimpan perubahan...");   
   }   
  } else {   
   die("Akses dilarang...");   
  }   
  ?>   
8. proses edit.php

  <?php   
  include("config.php");   
  if(isset($_POST['daftar'])){   
   $nama = $_POST['nama'];   
   $alamat = $_POST['alamat'];   
   $jk = $_POST['jenis_kelamin'];   
   $agama = $_POST['agama'];   
   $sekolah = $_PO  
   $sql = "INSERT INTO calon_siswa (nama, alamat, jenis_kelamin, agama, sekolah_asal) VALUE ('$nama', '$alamat', '$jk', '$agama', '$sekolah')";   
   $query = mysqli_query($db, $sql);   
   if( $query ) {    
    header('Location: index.php?status=sukses');   
   } else {   
    header('Location: index.php?status=gagal');   
   }   
  } else {   
   die("Akses dilarang...");   
  }   
  ?>   

Minggu, 14 Oktober 2018

PBO- A UTS Electronic Parking System

Pada hari ini saya mendapatkan tugas membuat sitem parkir otomatis yang sudah diterapkan di Surabaya lebih tepatnya Taman Bungkul menggunakan bahasa Java. Berikut saya lampirkan hasil compilenya:
Berikut saya lampirkan puila source codenya:

 import java.util.Scanner;  
 public class utama  
 {  
   private int x, y, durasi, tarif;  
   private String nopol;  
   public utama()  
   {  
     Scanner input = new Scanner(System.in);  
     System.out.println("Tekan 1 untuk mobil, 2 untuk motor, 3 untuk sepeda");  
     int x = input.nextInt();  
     System.out.println("Masukkan nomor polisi kendaraan anda;");  
     String nopol = input.next();  
     System.out.println("Berapa lama anda akan parkir disini");  
     int durasi = input.nextInt();  
     System.out.println("Jam");  
     if(x==1){  
       tarif = durasi * 5000;  
   }  
     if(x==2){  
       tarif = durasi * 2000;  
   }  
     if(x==3){  
       tarif = durasi * 500;  
   }  
     System.out.println(tarif+" Rupiah. Silakan tempelkan kartu anda");  
     System.out.println("Jika sudah silahkan tekan angka 1");  
     int y = input.nextInt();  
     if(y==1){  
       System.out.println("Terima kasih telah melakukan pembayaran untuk kendaraan dengan nopol:"+nopol+  
       ",dengan durasi parkir:"+durasi+" ,dan total tarif:"+tarif);  
       System.out.println("Silakan ambil tiket yang 1 diperuntukkan taruh di kendaraan anda, yang satunya lagi anda simpan. Jika tiket hilang denda Rp.50.000,-");  
 }  
 }  
 }  

PBO A Techsupport

Pada kesempatan kali ini saya mendapat tugas membuat techsupport berikut saya lampirkan hasil dari programnya:
berikut saya lampirkan pula source codenya:
1. Support system
 public class SupportSystem    
  {    
  private InputReader reader;    
  private Responder responder;    
  public SupportSystem()    
  {    
  reader = new InputReader();    
  responder = new Responder();    
  }    
  public void start()    
  {    
  boolean finished = false;    
  printWelcome();    
  while(!finished) {    
  String input = reader.getInput();    
  if(input.startsWith("bye")) {    
  finished = true;    
  }    
  else {    
  String response = responder.generateResponse();    
  System.out.println(response);    
  }    
  }    
  printGoodbye();    
  }    
  private void printWelcome()    
  {    
  System.out.println(    
  "ketik 'bye' untuk membehrntikan program ini.");  
  }    
  private void printGoodbye()    
  {    
  System.out.println("dadah.");    
  }    
  }    

2. Input reader
 import java.util.Scanner;    
  public class InputReader    
  {    
   public String getInput()    
   {    
   Scanner input = new Scanner(System.in);    
   String in = input.nextLine();    
   return in;    
   }    
  }    

3. Responder
 public class Responder    
  {    
   public Responder()    
   {    
   }    
   public String generateResponse()    
   {    
   return "Opo?";    
   }    
  }    

Selasa, 09 Oktober 2018

PWEB-C formulir tagihan

Pada kesempatan kali ini saya berkesempatan membuat fromulir tagihan listrik. Berikut saya lampirkan source codenya:
1. index.php

 <?php  
  session_start();  
 ?>  
 <!DOCTYPE html>  
  <head>  
  <link rel="stylesheet" href="style.css">  
  </head>  
  <body>  
  <div id="wrapshopcart">  
   <h1>Form Registrasi</h1>  
   <p>Silakan lengkapi form di bawah ini untuk membayar tagihan anda (*=wajib). </p>  
   <form action="invoice.php" method="POST">  
   <label>Nama Depan* : </label><input type="text" name="nama_depan" class="inputan" required />  
   <label>Nama Belakang : </label><input type="text" name="nama_belakang" class="inputan" />  
   <label>Email* : </label><input type="email" name="email" class="inputan" required />  
      <br>  
   <label>No Pelanggan* : </label><input type="number" name="no_pel" class="inputan" required pattern=".{6,}" />  
  <br>  
   <label>No Telp : </label><input type="text" name="no_telp" class="inputan" />  
  <br>  
   <label>Alamat* :</label><textarea name="alamat" class="textan" required></textarea>  
   <input type="submit" name="kirim" value="Kirim Isi Formulir!" class="submitbtn" />  
   </form>  
  </div>    
  </body>  
 </html>  
2. tagihan.php

 <?php  
  session_start();  
  $total = NULL;  
  $post = $_POST;  
  $_SESSION['cart'] = array(  
     array('productid' => 'TL01', 'product' => 'Listrik yang terpakai (Kwh)' , 'qty' => 57.67       ),  
     array('productid' => 'BA01', 'product' => 'Biaya Administrasi' , 'qty' => 1),  
     array('productid' => 'PJ01', 'product' => 'Pajak' , 'qty' => 1)  
    );  
  $_SESSION['price'] = array(  
     'TL01' => 1600,  
     'BA01' => 5000,  
     'PJ01' => 10000  
    );   
 ?>  
 <!DOCTYPE html>  
  <head>  
  <link rel="stylesheet" href="invoice.css">  
  </head>  
  <body>  
   <div id="wrapshopcart">  
   <h1>Invoice 637462i9</h1>  
   <p>Silahkan save halaman ini. </p>  
   <h3>Berikut adalah data lengkap Anda : </h3>  
   </label><table><tr></tr></table>  
   <label>Nama Lengkap : <?php echo $post['nama_depan'] . ' ' . $post['nama_belakang'] ;?> </label><table><tr></tr></table>  
   <label>Email : <?php echo $post['email'] ;?> </label></label><table><tr></tr></table>  
   <label>No Pelanggan: <?php echo $post['no_pel'] ;?></label></label><table><tr></tr></table>  
   <label>No Telp : <?php echo $post['no_telp'] ;?></label></label><table><tr></tr></table>  
   <label>Alamat : <?php echo $post['alamat'] ;?></label></label><table><tr></tr></table>  
   <h3>Total tagihan anda: </h3>  
   <table>  
   <tr><th width="70%">Produk</th><th width="10%">Quantity</th><th width="20%">Jumlah</th></tr>  
   <?php foreach($_SESSION['cart'] as $row):?>  
    <?php   
    $jumlah = $_SESSION['price'][$row['productid']] * $row['qty'];   
    $total += $jumlah;  
    ?>  
    <tr><td><?php echo $row['product'];?></td><td><?php echo $row['qty'];?></td><td><?php echo $jumlah; ?></td></tr>  
   <?php endforeach;?>  
   <tr class="total"><td></td><td >Total</td><td><?php echo $total;?></td></tr>  
   </table>    
   <h3>Silahkan Lakukan Pembayaran Ke Kantor PLN terdekat</h3>  
  </div>   
  </body>  
 </html>  
3. style.css

  body  
  {  
    background:#fff;  
    font-family:arial;  
  }  
  #wrapshopcart  
  {  
    width:70%;  
    margin:3em auto;  
    padding:30px;  
    background:#efefef;  
    box-shadow:0 0 15px #ddd;  
  }  
  h1  
  {  
    margin:0;  
    padding:0;  
    font-size:2.5em;  
    font-weight:bold;  
  }  
  p  
  {  
    font-size:1em;  
    margin:0;  
  }  
  table  
  {  
    margin:2em 0 0 0;  
    border:1px solid #eee;  
    width:100%;  
    border-collapse: separate;  
    border-spacing:0;  
  }  
  table th  
  {  
    background:#fafafa;  
    border:none;  
    padding:20px ;  
    font-weight:normal;  
    text-align:left;  
  }  
  table td  
  {  
    background:#fff;   
    border:none;  
    padding:12px 20px;   
    font-weight:normal;  
    text-align:left;   
    border-top:1px solid #eee;  
  }  
  table tr.total td  
  {  
    font-size:1.5em;  
  }  
  .btnsubmit  
  {  
    display:inline-block;  
    padding:10px;  
    border:1px solid #ddd;  
    background:#eee;  
    color:#000;  
    text-decoration:none;  
    margin:2em 0;  
  }  
  form  
  {  
    margin:2em 0 0 0;  
  }  
  label  
  {  
    display:inline-block;  
    width:12em;  
  }  
  input[type=text]  
  {  
    border:1px solid #bbb;  
    padding:10px;  
    width:30em;  
  }  
  textarea  
  {  
    border:1px solid #bbb;  
    padding:10px;  
    width:30em;  
    height:5em;  
    vertical-align:text-top;  
    margin:0.3em 0 0 0;  
  }  
  .submitbtn  
  {  
    font-size:1.5em;  
    display:inline-block;  
    padding:10px;  
    border:1px solid #ddd;  
    background:#eee;  
    color:#000;  
    text-decoration:none;  
    margin:0.5em 0 0 8em;  
  };  
4. invoice.css

  body  
  {  
    background:#fff;  
    font-family:arial;  
   }  
  #wrapshopcart  
  {  
    width:70%;  
    margin:3em auto;  
    padding:30px;  
    background:#efefef;  
    box-shadow:0 0 15px #ddd;  
   }  
  h1  
  {  
    margin:0;  
    padding:0;  
    font-size:2.5em;  
    font-weight:bold;  
   }  
  p  
  {  
    font-size:1em;  
    margin:0;  
   }  
  table  
  {  
    margin:2em 0 0 0;  
    border:1px solid #eee;  
    width:100%;   
    border-collapse: separate;  
    border-spacing:0;  
   }  
  table th  
  {  
    background:#fff;  
    border:none;  
    padding:20px ;  
    font-weight:normal;  
    text-align:left;  
   }  
  table td  
  {  
    background:#efefef;   
    border:none;   
    padding:12px 20px;  
    font-weight:normal;  
    text-align:left;   
    border-top:1px solid #eee;  
   }  
  table tr.total td  
  {  
    font-size:1.5em;  
   }  
  .btnsubmit  
  {  
    display:inline-block;  
    padding:10px;  
    border:1px solid #ddd;  
    background:#eee;  
    color:#000;  
    text-decoration:none;  
    margin:2em 0;  
   }  
  form  
  {  
    margin:2em 0 0 0;  
   }  
  label  
  {  
    display:inline-block;  
    width:auto;  
   }  
  input[type=text]  
  {  
    border:1px solid #bbb;  
    padding:10px;  
    width:30em;  
   }  
  textarea  
  {  
    border:1px solid #bbb;  
    padding:10px;  
    width:30em;  
    height:5em;  
    vertical-align:text-top;  
    margin:0.3em 0 0 0;  
   }  
  .submitbtn  
  {  
    font-size:1.5em;  
    display:inline-block;  
    padding:10px;  
    border:1px solid #ddd;  
    background:#eee;  
    color:#000;  
    text-decoration:none;  
    margin:0.5em 0 0 8em;  
  }  
  </style>  

Berikut saya lampirkan pula hasil compilenya;
1. halaman formulir

2. halaman tagihan

Minggu, 07 Oktober 2018

PBO A Membuat Program Lelang

pada kesempatan ini saya belajar membuat program lelang menggunakan Bahasa Java dengan BlueJ. berikut saya lampirkan hasilnya:

1. Source Code Auction

 /**  
  * Write a description of class auction here.  
  *  
  * @author (Shawn Timothy Mulya P)  
  * @version (03.10)  
  */  
  import java.util.ArrayList;   
  import java.util.Iterator;   
  public class Auction   
  {   
   // The List of Lots in this auction.   
   private ArrayList<Lot> lots;   
   // The number that will be given to the next lot entered   
   // into this auction   
   private int nextLotNumber;   
   /**   
   * Create a new auction   
   */   
   public Auction()   
   {   
    lots = new ArrayList<Lot>();   
    nextLotNumber = 1;   
   }   
   /**   
   * Enter a new lot into the auction.   
   * @param description A description of the lot.   
   */   
   public void enterLot(String description)   
   {   
    lots.add(new Lot(nextLotNumber, description));   
    nextLotNumber++;   
   }   
   /***    
   * Show the full list of lots in this auction.   
   */   
   public void showLots()   
   {   
    for(Lot lot : lots){   
     System.out.println(lot.toString());   
    }   
   }   
   /**   
   * Bid for a lot.   
   * A message indicating whether the bid is succesful or not is printed.   
   * @param number The lot number being bid for.   
   * @param bidder The person bidding for the lot.   
   * param value The value of the bid.   
   */   
   public void bidFor(int lotNumber, Person bidder, long value)   
   {   
    Lot selectedLot = getLot(lotNumber);   
    if(selectedLot!=null){   
     boolean successful = selectedLot.bidFor(new Bid(bidder,value));   
     if (successful) {   
      System.out.println("The bid for lot number " + lotNumber +    
      " was successful.");   
     }   
     else {   
      //Report which bid is higher.   
      Bid highestBid = selectedLot.getHighestBid();   
      System.out.println("Lot number: " + lotNumber +    
      " already has a bid of: " + highestBid.getValue());   
     }   
    }   
   }   
   /**   
   * Return a list of the unsold lots.   
   */   
   public void close()   
   {   
    System.out.println("The auction is closed.");   
    for(Lot lot : lots) {   
     System.out.println(lot.getNumber() + ": " +lot.getDescription());   
     Bid bid = lot.getHighestBid();   
     if (bid==null){   
      System.out.println("(No Bids for this lot.)");   
     }   
     else {   
      System.out.println( "sold to " +    
      bid.getBidder().getName() + " for "    
      + bid.getValue());   
    }   
   }   
  }   
   /**    
   * Return the lot with the given number.    
   * Return null if a lot with this number does not exist.   
   * @param lotNumber The number of the lot to return.   
   */   
   public Lot getLot(int lotNumber)   
   {   
    if((lotNumber >= 1) && (lotNumber < nextLotNumber)) {   
     // The number seems to be reasonable.   
     Lot selectedLot = lots.get(lotNumber - 1);   
     // Include a confidence check to be sure we have the right lot.   
     if(selectedLot.getNumber() != lotNumber) {   
      System.out.println("Internal error: lot number " +   
      selectedLot.getNumber() + " was returned instead of " +    
      lotNumber);   
      // Don't return invalid lot.   
      selectedLot = null;   
      }   
      return selectedLot;   
     }   
    else {   
     System.out.println("lot number: " + lotNumber + " does not exist.");   
     return null;   
     }   
    }   
   }   

2.Source Code Lot

 /**  
  * Write a description of class Lot here.  
  *  
  * @author (Shawn Timothy Mulya P)  
  * @version (03.10)  
  */  
 public class Lot   
  {   
   // A unique identifying number.   
   private final int number;   
   //A description of the lot.   
   private String description;   
   // The current highest bid for this lot.   
   private Bid highestBid;   
   /**   
   * Construct a Lot, setting its number and description.   
   * @param number The lot number.   
   * @param description A description of this lot.   
   */   
   public Lot(int number, String description)   
   {   
    this.number = number;   
    this.description = description;   
   }   
   /**   
   * Attempt to bid for this lot. A successful bid   
   * must have a value higher than any existing bid.   
   * @param bid A new bid.   
   * @return true if successful, false otherwise.   
   */   
   public boolean bidFor(Bid bid)   
   {   
    if((highestBid == null)||(bid.getValue() > highestBid.getValue()))   
    {   
     // This bid is the best so far   
     highestBid = bid;   
     return true;   
    }   
    else{   
     return false;   
    }   
   }   
   /**   
   * @return A string representation of this lot's details.   
   */   
   public String toString()   
   {   
    String details = number + ": " + description;   
    if(highestBid!=null) {   
     details+= " Bid: " +highestBid.getValue();   
    }   
    else {   
     details += " (No bid)";   
    }   
    return details;   
   }   
   /**   
   * @return The lot's number.   
   */   
   public int getNumber()   
   {   
    return number;   
   }   
   /**   
   * @return The lot's description.   
   */   
   public String getDescription()   
   {   
    return description;   
   }   
   /**   
   * @return The highest bid for this lot.   
   * This could be null if there is no current bid.   
   */   
   public Bid getHighestBid()   
   {   
    return highestBid;   
   }   
  }   

3. Source Code Bid

 /**  
  * Write a description of class bid here.  
  *  
  * @author (Shawn Timothy Mulya P)  
  * @version (03.10)  
  */  
 public class Bid   
  {   
   // The person making the bid   
   private final Person bidder;   
   // The value of the bid. This could be a large number so the long type has been used   
   private final long value;   
   /**   
   * Create a bid   
   * @param bidder Who is bidding for the lot.   
   * @param value The value of the bid.   
   */   
   public Bid(Person bidder, long value)   
   {   
    this.bidder = bidder;   
    this.value = value;   
   }   
   /**   
   *@return The bidder.   
   */   
   public Person getBidder()   
   {   
    return bidder;   
   }   
   /**   
   * @return The value of the bid.   
   */   
   public long getValue()   
   {   
    return value;   
   }   
  }   

4. Source Code Person

 /**  
  * Write a description of class person here.  
  *  
  * @author (Shawn Timothy Mulya P)  
  * @version (03.10)  
  */  
  public class Person   
  {   
   // The name of this person.   
   private final String name;   
   /**   
   * Create a new person with the given name.   
   * @param name The person's name.   
   */   
   public Person(String name)   
   {   
    this.name = name;   
   }   
   /**   
   * @return The Person's name*   
   */   
   public String getName()   
   {   
    return name;   
   }   
  }   


Hasil:


Selasa, 02 Oktober 2018

PWEB C Membuat form

pada kesempatan ini saya melanjutkan web saya yang sebelumnya membuat website berita dengan menambahkan halaman form sign up. berikut saya lampirkan hasilnya:
berikut saya lampirkan pula sorce codenya:
1. html

 <!DOCTYPE html>   
  <html>   
  <head>   
    <title>Sign Up</title>   
    <link rel="stylesheet" type="text/css" href="style.css">   
  </head>   
  <body>   
    <center><h2>SIGN UP FOR FREE</h2></center>   
    <div class="login">   
       <form action="#" method="POST" onSubmit="validasi()">   
         <div>   
            <label>Nama Lengkap:</label>   
            <input type="text" name="nama" placeholder="Enter Your Name" id="nama" maxlength="50" required />   
         </div>   
         <div>   
            <label>Alamat:</label>   
            <textarea cols="40" rows="5" name="alamat" placeholder="Enter Your Address" id="alamat" required ></textarea>   
         </div>   
         <div>   
            <label>Email:</label>   
            <input type="email" name="email" placeholder="Enter E-mail"id="email" required />   
         </div>   
         <div>   
            <label>No Hp:</label>   
            <input type="phone" name="phone" placeholder="Enter Your Phone Number" id="phone" min="11" max="13" required/>   
         </div>   
         <div>   
            <label>Jenis Kelamin: </label> <br/>   
            <input type="radio" name="gender" value="male" /> L <br/>   
            <input type="radio" name="gender" value="female" /> P <br/>   
         </div>   
         <div>   
    <label>Tanggal Lahir:</label>   
    <input type="date" id="birthday" name="birthday" id="birthday"   
      min="01-01-1900" max="31-12-2018" required />   
   </div>   
    <div>   
            <label>Kolom Favorit:</label>   
            <input type="text" name="fav" list="fav" placeholder="Teknologi,Olahraga, etc" required/>    
      <datalist id="fav">    
      <option value="Teknologi"></option>    
      <option value="Olahraga"></option>    
      <option value="Politik"></option>    
      <option value="Ekonomi"></option>    
      <option value="Lainnya"></option>    
      </datalist>    
         </div>   
         <div>   
         <label>Password:</label>   
          <input type="text" placeholder="Enter Password" name="pass" required>    
          </div>   
         <div>   
            <input type="submit" value="Sign Up" class="tombol">   
         </div>   
       </form>   
    </div>   
  </body>   
  <script type="text/javascript">   
    function validasi() {   
       var nama = document.getElementById("nama").value;   
       var alamat = document.getElementById("alamat").value;   
       var email = document.getElementById("email").value;   
       var phone = document.getElementById("phone").value;   
       var gender = document.getElementById("gender").value;   
       var birthday = document.getElementById("birthday").value;   
       var fav = document.getElementById("fav").value;   
       var maxhuruf = 50;   
       pola_email=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;   
    if (!pola_email.test(form.email.value)){   
   alert ('Penulisan Email tidak benar');   
   form.email.focus();   
   return false;   
  }   
       if (form.nama.value.length > maxhuruf){   
   alert("Batas Maksimal adalah 50 Karakter");   
   form.nama.focus();   
   return (false);   
       }   
       if (nama = "" || email="" || alamat ="" || phone ="" || gender ="" || birthday ="" || fav ="") {   
         alert('Anda harus mengisi data dengan lengkap !');   
         return (false);}   
  }   
    }   
  </script>   
  </html>   

2. CSS
 body {  
  background: #fff;   
  color: #333;   
  width: 100%;   
  font-family: sans-serif;   
  margin: 0 auto;   
 }  
 h2 {  
  color: #EA2323;  
 }  
 .login {  
  padding: 1em;  
  margin: 2em auto;  
  width: 17em;  
  background: #BF1F1F;  
  border-radius: 3px;  
 }  
 label {  
  font-size: 10pt;  
  color: #fff;  
 }  
 input[type="text"],  
 input[type="email"],  
 input[type="phone"],  
 input[type="date"],  
 textarea {  
  padding: 8px;  
  width: 95%;  
  background: #efefef;  
  border: 0;  
  font-family: "lato", cursive, sans-serif;  
  font-size: 10pt;  
  margin: 6px 0px;  
 }  
 .tombol {  
  background: #FF7F50;  
  color: #fff;  
  border: 0;  
  padding: 5px 8px;  
 }