Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Document : 1
- Created on : Oct 14, 2019, 8:38:26 AM
- Author : mrpds
- --%>
- <%@page contentType="text/html"%>
- <%@page pageEncoding="UTF-8"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Contoh if - else</title>
- </head>
- <body>
- <FORM method="post">
- <BR> <BR>
- <BR>
- <tr>
- <td>Kota Tujuan</td>
- <td>:</td>
- <td>
- <select name="tujuan">
- <option value="0">Pilih</option>
- <option value="1">Solo</option>
- <option value="2">Semarang</option>
- <option value="3">Yogyakarta</option>
- <option value="4">Surabaya</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Jumlah nilai</td>
- <td>:</td>
- <td>
- <input type="text" name="nilai"></td>
- </td>
- </tr>
- <INPUT TYPE=SUBMIT VALUE="Proses">
- </FORM>
- <%
- String strNilai = request.getParameter("nilai");
- String strSolo = request.getParameter("solo");
- String tujuan = request.getParameter("num");
- int solo;
- solo=450000;
- if (strNilai == null)
- strNilai = "0";
- if (strSolo == null)
- strSolo = "0";
- if (request.getParameter("tujuan") != null && request.getParameter("tujuan")!="")
- {
- for(int i=0; i<request.getParameter("tujuan").length(); i++)
- {
- char value = request.getParameter("tujuan").charAt(i);
- switch(value)
- {
- case '0' :
- out.print("<br><br>Please Select Your Location... <br><br>");
- break;
- case '1' :
- out.print("<br><br>Solo <br><br>");
- int nilai = Integer.valueOf(strNilai).intValue();
- if (nilai >= 3)
- {
- out.println("Harga = " + nilai + "<br>");
- out.println("Diskon = " + solo );
- }
- else if (nilai >= 10)
- out.println("Nilai ujian = " + nilai + " kamu tidak lulus");
- else
- out.println("none");
- break;
- }
- }
- }
- %>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement