The Pet Age Calculator
The Pet Age Calculator

The Pet Age Calculator

by Julia Green

Introduction

There are many Cat Age Calculators on the web these days but I developed this one in Active Server Pages which converts a cat's actual years to people years. Many of us have an unusual affinity for our pets, and this is a way of making us feel better that they are actual human beings inside. I also programmed a Dog Age Calculator which is beneath the Cat Age Calculator code, for those of us with a canine in mind.

The Cat Age Calculator

The first ASP page has two text boxes, one for our cat's or dog's name, and the other for their actual years. You can put actual names and years as the default values which I have, and have other people change them accordingly. The background and pictures of course are totally up to you - I put the sound of a cat's meow on mine. These are great things to develop for kids and small students, and someday (maybe sooner or later), they may actually understand that VBScript!

For an example, please go to http://www.juliagreen.com/cat.asp.

The FORM itself

<html>



<head>

<style type="text/css">

img { border: 10px double #E6D1B3 }

h1 { color : #800080; }

p { color : #800080; }

</style>

<title>Cat Age Calculator</title>

<bgsound src="images/meow.wav" loop="2">

</head>



<body>



<center>



<h1>Julie's Cat Age Calculator</h1>



<img src="images/cat.jpg" width="400" height="300">



<p>

A cat is considered to be senior when they are 8 to 10

years of age.  Cat's over 12 years of age are considered

geriatric.  Phoenix, my house cat, is 12 years old.

</p>

<p>

To all those cats out there!

The longest a cat has ever lived is 34 years.

</p>



<form action="cat2.asp" method="post">

<p>

<b>What is the name of your cat?</b>

</p>

<p>

<input type="text" name="name" size="10" value="Phoenix">

</p>



<p>

<b>What is the age of your cat in real years?</b>

</p>

<p>

<input type="text" name="age" size="10" value="12"> years

</p>



<input type="submit"><input type="reset">

</form>



</center>



</body>

</html>


The Resulting ASP Code

<%@ Language = VBScript %>

<% Option Explicit %>

<html>

<head>

<style type="text/css">

img { border: 10px double #E6D1B3 }

h1 { color : #9900CC; }

p { color : #9900CC; }

</style>

<title>Cat Age Calculator</title>

<bgsound src="images/meow.wav" loop="2">

</head>



<body>



<center>



<h1>Cat Age Calculator Answer</h1>



<%

Dim varName, varAge

Dim age2



varName=Request.Form("name")

varAge=Request.Form("age")



If varAge = 1 Then

	age2 = 15

End If

If (varAge > 1) Then

	age2 = (varAge * 5) + 10

End If

If varAge = 7 Then

	age2 = 45

End If

If (varAge > 7) Then

	age2 = (varAge * 4) + 17

End If

If varAge=10 Then

	age2 = 58

End If

If (varAge > 10) Then

	age2 = (varAge * 5) + 8

End If

If varAge=15 Then

	age2 = 78

End If

If (varAge>15) Then

	age2 = (varAge * 4) + 18

End If

If varAge=20 Then

	age2 = 98

End If

If varAge > 20 Then

Response.Write "<br><center><h1>You're over 100 kitty!</h1>"

End If

%>



<p><font size="+2">

<%= varName %>'s people age is <%= age2 %> years.

</font></p>



<p>

<img src="images/kitty.jpg" height="248">

</p>

<p>

<a href="cat.asp">Go back to Cat Calculator!!</a>

</p>



</center>



</body>

</html>

The Dog Age Calculator

The same technique is used, an ASP page with a name and age textbox. I've just put the resulting asp code here, instead of the originating page.

For an example, go to http://www.juliagreen.com/dog.asp.

Dog2.asp or the result of a form asking name and age.



<center>

<b><i><font size=+2 color=#800000>

<%

Dim varName, varAge

Dim age2



varName=Request.Form("name")

varAge=Request.Form("age")



If varAge = 1 Then

	age2 = 15

End If

If varAge = 2 Then

	age2 = 24

End If

If varAge > 2 Then

	age2 = 15 + (varAge * 4)

End If



If varAge = 21 Then

	%>

	<%= varName %>!  You're one year short of a 100!

	That's a doggone long time!

	<%

End If

If varAge>21 Then

	%>

	<%= varName %>!  Guess what, you're a Centurion!

	<%

End If

%>



<p>

<%= varName %>'s people age is <%= age2 %> years.

</p>



<p>

<a href="dog.asp">Go back to Dog Calculator!!</a>

</p>

<p>

<a href="cat.asp">Go back to Cat Calculator!!</a>

</p>



</font></i></b>

</center>

Close    To Top
  • Prev Article-Web Design:
  • Next Article-Web Design:
  • Now: Tutorial for Web and Software Design > Web Design > ASP > Web Design Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction