Wednesday, 17 October 2012
My four folio items
Folio 1:
//Convert a given temperature to a comment on the weather
var temp = prompt("Enter Temperate in Degrees Celsius")
//Gather temperature data from the user and set the var temp to it.
if(temp < 0)
//if statement tests for entered temperature and categorises it accordingly {
document.write("It's freezing out there!")
}
else if(temp > 25) //High temp
{
document.write("It's hot out there!")
}
else //i.e. 0 <= temp <= 25
{
document.write("You don't need skis or boardshorts")
}
Folio 2:
var width = prompt("Enter the width of the window in meters:")
var height = prompt("Enter the height of the window in meters:")
var sqm = prompt("Enter the price per square meter in $:")
document.write("Width = "+width)
document.write("<br>")
document.write("Height = "+height)
document.write("<br>")
document.write("Area = "+(height*width))
document.write("<br>")
document.write("Price = $"+(height*width*sqm))
Folio 3:
var noPizza = prompt("Please enter the number of pizzas:")
//get no. of pizzas
var toppings = prompt("Please enter the toppings per pizza:")
//get no. of toppings every pizza
var toppingstotal = noPizza*toppings
//calculate the total no. of toppings required
var baseprice = noPizza*7
// coz each pizza costs $7
var toppingsprice = toppingstotal*0.6
//coz each topping costs 60 cents
var totalcost = baseprice+toppingsprice
document.write("Your order price is $"+ totalcost)
Folio 4:
var name = prompt("Please enter your name:")
var no1 = parseInt(prompt("Please enter the first number of your operation"))
var no2 = parseInt(prompt("Please enter the second number of your operation"))
var op = prompt("Please enter the mathematical operation (+, -, * or /)")
if (op === "+")
{
document.write(no1 + no2)
}
else if (op === "-")
{
document.write(no1 - no2)
}
else if (op === "*")
{
document.write(no1 * no2)
}
else if (op === "/")
{
document.write(no1 / no2)
}
document.write("<br><br>")
document.write("Well done "+name)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment