Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. <%--
  2. Document : 1
  3. Created on : Oct 14, 2019, 8:38:26 AM
  4. Author : mrpds
  5. --%>
  6.  
  7. <%@page contentType="text/html"%>
  8.  
  9. <%@page pageEncoding="UTF-8"%>
  10.  
  11. <!DOCTYPE html>
  12. <html>
  13.  
  14. <head>
  15.  
  16. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  17.  
  18. <title>Contoh if - else</title>
  19.  
  20. </head>
  21.  
  22. <body>
  23.  
  24.  
  25.  
  26.  
  27.  
  28. <FORM method="post">
  29.  
  30. <BR> <BR>
  31. <BR>
  32.  
  33.  
  34. <tr>
  35. <td>Kota Tujuan</td>
  36. <td>:</td>
  37. <td>
  38. <select name="tujuan">
  39. <option value="0">Pilih</option>
  40. <option value="1">Solo</option>
  41. <option value="2">Semarang</option>
  42. <option value="3">Yogyakarta</option>
  43. <option value="4">Surabaya</option>
  44. </select>
  45. </td>
  46. </tr>
  47.  
  48. <tr>
  49. <td>Jumlah nilai</td>
  50. <td>:</td>
  51. <td>
  52. <input type="text" name="nilai"></td>
  53. </td>
  54. </tr>
  55.  
  56.  
  57. <INPUT TYPE=SUBMIT VALUE="Proses">
  58.  
  59. </FORM>
  60.  
  61.  
  62.  
  63.  
  64. <%
  65. String strNilai = request.getParameter("nilai");
  66. String strSolo = request.getParameter("solo");
  67. String tujuan = request.getParameter("num");
  68. int solo;
  69. solo=450000;
  70. if (strNilai == null)
  71. strNilai = "0";
  72. if (strSolo == null)
  73. strSolo = "0";
  74.  
  75. if (request.getParameter("tujuan") != null && request.getParameter("tujuan")!="")
  76. {
  77. for(int i=0; i<request.getParameter("tujuan").length(); i++)
  78. {
  79. char value = request.getParameter("tujuan").charAt(i);
  80. switch(value)
  81. {
  82.  
  83. case '0' :
  84. out.print("<br><br>Please Select Your Location... <br><br>");
  85. break;
  86.  
  87. case '1' :
  88. out.print("<br><br>Solo <br><br>");
  89. int nilai = Integer.valueOf(strNilai).intValue();
  90.  
  91. if (nilai >= 3)
  92. {
  93. out.println("Harga = " + nilai + "<br>");
  94. out.println("Diskon = " + solo );
  95. }
  96.  
  97. else if (nilai >= 10)
  98. out.println("Nilai ujian = " + nilai + " kamu tidak lulus");
  99. else
  100. out.println("none");
  101. break;
  102.  
  103.  
  104.  
  105.  
  106. }
  107. }
  108. }
  109. %>
  110.  
  111.  
  112.  
  113.  
  114. </body>
  115.  
  116. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement