Advertisement
Guest User

Untitled

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