Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php error_reporting(0); ?>
- <head>
- <title>Tugas Praktikum 2</title>
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
- <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
- <style type="text/css">
- body {
- background-image: linear-gradient(to right, #a1c4fd 0%, #c2e9fb 51%, #a1c4fd 100%) !important;
- padding-top: 1em;
- };
- </style>
- <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
- <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
- </head>
- <body>
- <div class="container">
- <div class="row justify-content-md-center">
- <div class="col col-lg-6">
- <h4 class="text-center">Tugas Praktikum 2 - Bilangan Ganjil dan Genap</h4>
- <form action="" method="post">
- <div class="form-group">
- <label for="nama">Angka Awal</label>
- <input type="text" autocomplete="off" class="form-control" name="awal" placeholder="Angka Awal" required>
- </div>
- <div class="form-group">
- <label for="nama">Angka Akhir</label>
- <input type="text" autocomplete="off" class="form-control" name="akhir" placeholder="Angka Akhir" required>
- </div>
- <div class="form-group">
- <button type="submit" class="btn btn-primary" name="submit">Proses</button>
- </div>
- </form>
- <!-- Info -->
- <div id="info" class="alert alert-warning">
- <?php
- // Class
- class coba
- {
- // Fungsi
- public function test($angka1,$angka2)
- {
- // echo $angka1.' dan '.$angka2;
- for ($i=$angka1; $i<=$angka2 ; $i++) {
- if($i%2){
- $ganjil[] = $i;
- }else{
- $genap[] = $i;
- }
- }
- echo '<p>Bilangan Ganjil: '. trim(json_encode($ganjil,JSON_NUMERIC_CHECK),'[]') .'</p>';
- echo '<p>Bilangan Genap: '. trim(json_encode($genap,JSON_NUMERIC_CHECK),'[]') .'</p>';
- }
- }
- if (isset($_POST['submit'])) {
- $a = new coba();
- echo $a->test($_POST['awal'],$_POST['akhir']);
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- </body>
- <blockquote class="blockquote text-center">
- <footer class="footer"><h6>Alwi Adib Novianto - 2017103634</h6></footer>
- </blockquote>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement