CTH FA dfp50283 Sesi2 20222023
CTH FA dfp50283 Sesi2 20222023
Keperluan:
CLO 1 Write Servlet page to calculate the area of circle. Data input must be entered via HTML page.
P4
Cipta halaman Servlet untuk mengira mengira luas bulatan. Input data perlulah dimasukkan
melalui halaman html.
a) Based on Figure 1, create form using HTML and named as circle.html. The form is used
to accepts input from users via a textfield. The data input is radius. This data will be
sent to the Servlet page, which is circle.java (Figure 2).
b) By using the Servlet code, create the circle.java (Figure 2) page which receives the data
sent from the circle.html page to calculate area of circle.
Dengan menggunakan kod Servlet, cipta halaman circle.java (Rajah 2) untuk menerima
input data dari halaman circle.html bagi mengira luas bulatan.
QUESTION 2
SOALAN 2
CLO 1 Write a JSP(Java Server Pages) to calculate the price of bus ticket from Ipoh Town to other
P4
destination. Data input must be entered via JSP page.
Cipta JSP(Java Server Pages) untuk mengira harga tiket bas dari bandar Ipoh ke destinasi
yang lain. Input data perlulah dimasukkan melalui halaman JSP.
a) Based on Figure 3, create form using JSP and named as ticket.jsp. The form is used to
accept input from users via a textfield and radio button. The data inputs are:
i) name of buyer;
ii) destination; and
iii) quantity.
This data will be sent to the second JSP page, which is price.jsp (Figure 4.jsp).
Berdasarkan Rajah 3, cipta borang menggunakan JSP dan namakan sebagai ticket.jsp.
Borang ini digunakan untuk menerima input data dari pengguna melalui textfield dan radio
button. Data yang diinput adalah:
i) nama pembeli;
ii) destinasi; dan
iii) kuantiti.
Data ini akan di hantar ke halaman JSP yang kedua iaitu price.jsp (Rajah 4.jsp).
Figure 4 : An example of JSP page with output data(price.jsp)
Rajah 4 : Contoh halaman JSP dengan data output(price.jsp)
b) Based on Figure 4, create the price.jsp page which receives the data sent from the
ticket.jsp (Figure 3) page. The function of the price.jsp page is as below:
• Total price of ticket will be calculated using the information in Table 1.
(use control structure : if)
• If the number of tickets exceeds 15 for each destination, a 30% discount will
be given to the total price.
• The output page (price.jsp) will displayed:
i) name of buyer;
ii) destination;
iii) quantity;
iv) price before discount;
v) discounted price; and
vi) total price.
Berdasarkan Rajah 4, cipta price.jsp untuk menerima input data dari halaman ticket.jsp
(Rajah 3). Fungsi halaman price.jsp adalah seperti di bawah.
• Jumlah harga tiket akan dikira dengan menggunakan maklumat dari Jadual 1.
(Guna kawalan struktur: if)
• Sekiranya bilangan tiket adalah melebihi 15 bagi setiap destinasi, sebanyak 30%
diskaun akan diberikan ke atas jumlah harga.
• Halaman output (price.jsp) akan memaparkan:
i) nama pembeli;
ii) destinasi;
iii) kuantiti;
iv) harga sebelum diskaun;
v) harga diskaun; dan
vi) jumlah harga.
END OF QUESTION
SOALAN TAMAT