Welcome! =D

Welcome to this page, KPOP World In Me.

Basically, this page is for my college purpose.

Last year (2013), I was required to create a blog and to talk about the things I like. Therefore, I promoted South Korea, and that was my topic for the assignment. To view them, checkout the sidebar, under the "My Previous Project" section.

As of this year (2014), for IT-subject, I was asked to create a blog again. So, I thought that I might as well use this existing blog and fortunately, my lecturer allowed me to do so.

In summary, all I want to say is that this is NOT a personal blog. Although the website is called "KPOP World", but it will contain non-KPOP related topics...

That is all from me. Happy reading~~ ^^

P/S - I found out that you need to refresh the page whenever you first open the page. This is to get the correct fonts that I've set for this page.

Friday, March 14

Tutorial 10

 Question 1. 1) & 2)

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="mystyle.css">
    </head>
    <body>
        <script type="text/javascript">
            var nescafe = prompt("Nescafe?","Enter Value");
            var apple = prompt("Apple?","Enter Value");
            var cocomilk = prompt("Coco Milk?","Enter Value");
            var maggiemee = prompt("Maggie Mee?","Enter Value");
       
            var nescafe_price = parseInt(nescafe)*10.50;
            var apple_price = parseInt(apple)*1.20;
            var cocomilk_price = parseInt(cocomilk)*1.50;
            var maggiemee_price = parseInt(maggiemee)*3.50;

            var subtotal = nescafe_price + apple_price + cocomilk_price + maggiemee_price;
           
            /* Display the receipt */
            document.write("<h2> ABC Shop Enterprise </h2>");
            document.write("<br>")

            document.write("<table>");

            document.write("<tr><th width=130px> Item</th>");
            document.write("<th width=120px> Price </th>");
            document.write("<th width=110px> Total </th></tr>");
           
            document.write("<tr><td>Nescafe @ " + nescafe + "</td>");
            document.write("<td>RM10.50</td>");
            document.write("<td>RM " + nescafe_price.toFixed(2) + "</td></tr>");

            document.write("<tr><td>Apple @ " + apple + "</td>");
            document.write("<td>RM1.20</td>");
            document.write("<td>RM " + apple_price.toFixed(2) + "</td></tr>");

           
            document.write("<tr><td>Coco Milk @ " + cocomilk + "</td>");
            document.write("<td>RM1.50</td>");
            document.write("<td>RM " + cocomilk_price.toFixed(2) + "</td></tr>");

           
            document.write("<tr><td>Maggie Mee @ " + apple + "</td>");
            document.write("<td>RM3.50</td>");
            document.write("<td>RM " + maggiemee_price.toFixed(2) + "</td></tr>");
           
            document.write("<tr><td class=white>" + "</td>");
            document.write("<td class=yellow>SubTotal" + "</td>");
            document.write("<td class=yellow>RM" + subtotal.toFixed(2) + "</td></tr>");
       
            document.write("<tr><td class=white>" + "</td>");
            document.write("<td class=yellow>GST" + "</td>");
            document.write("<td class=yellow>RM" + 0.06*subtotal.toFixed(2) + "</td></tr>");
           
            document.write("<tr><td class=white>" + "</td>");
            document.write("<td class=black >Grand Total" + "</td>");
            document.write("<td class=black >RM" + (subtotal+0.06*subtotal).toFixed(2) + "</td></tr>");
       
            document.write("</table>");
               
        </script>   
    </body>
</html>


mystyle.css

body{font-family: Arial;}

table.design{
        font-size:12px; }

th{
    background-color: #FFC42B; padding: 5px; font-weight: bold; }

td.black{
    background-color: #FFC42B; padding: 5px; font-weight: bold;
    color : black; }

td.yellow{
    background-color: yellow; padding: 5px;
     font-weight: bold; color : red; }
   
td.white{
    background-color: white; padding: 5px;
     font-weight: bold; color : red; }

td{
    background-color: #FFF7B8; color : #666666; padding: 5px;}


Question 1. 3)

<html>
    <body>

    <script type="text/javascript">
        var num1 = prompt("Enter interger");
        var num2 = prompt("Enter interger");

        var operator = prompt("Enter an operator");
       

        if (operator == "+") {
            var result = parseInt(num1)+ parseInt(num2);
            document.write(num1 + " + " + num2 + " = " + result + "<br>");
            }
        else if (operator == "*") {
            var result = parseInt(num1)*parseInt(num2);
            document.write(num1 + " * " + num2 + " = " + result + "<br>");
            }

        else if (operator == "/") {
            if (num2 == 0)
            alert(num1 + " / " + num2 + " = " + "Cannot divide by Zero");
            else
            var result = parseInt(num1)/parseInt(num2);
            document.write( result + "<br>");
            }
   
        else{
            alert("Invalid operator! Refresh and try again!");
            }
    </script>

    </body>
</html>

No comments:

Post a Comment