Hello

Welcome to my page!

Javascript

 
Links

Area and Perimeter

<script>
//Perimeter and Area
//Julio Maravilla
//September 18, 2007

//Declare Variables

var width;
var height;
var perimeter;
var halve;
var area;

//alerts
alert("In this program, I am going to find the area and the perimeter of a rectangle");

// get input for variables

width= prompt("What is the width of the rectangle?");
height= prompt("What is the height?");

//Change input into numbers

width=eval(width);
height=eval(height);

// Calculations

area= width * height;
halve= width + height;
perimeter= halve * 2;

// alerts

alert("The perimeter is " + perimeter + " .");
alert("The area is " + area + " .");

</script>

 

Links

Contact me

Favorite links

Computer Science

Five Classmates