Skip to main content

First HTML Page-week 2

        1.    Write an HTML page including any required JavaScript that takes a number from one text field in the range of 0 to 999 and shows it in another text field in words. If the number is out of range, it should show "out of range" and if it is not a number, it should show "not a number" message in the result box.

<html>
        <head>
        <title>WT Lab Experiment-2</title>
        </head>
        <body>
        <pre><b>
Input Box : <input type="text" name="t1" id="t1"> <input type="button" onclick=test() value="Submit"><br>
Result Box : <input type="text" name="t2" id="t2"><br>
        </b></pre>
        <script>
        function test()
        {
        var x;
        x = document.getElementById("t1").value;
        if (x<0)
        document.getElementById("t2").value="Out of Range";
        else if(x>999)
        document.getElementById("t2").value="Out of Range";
        else if(isNaN(x))
        document.getElementById("t2").value="Not a Number";
        else {
        var r,s=0,t="";
        while(x>0)   {
        r = x%10;
        s = s*10+r;
        x = parseInt(x/10);
        } x = s;
        while (x>0) {
        r = x%10;
        if (r==0)
        t = t+"Zero "; 
        if (r==1)
        t = t+"One "; 
        if (r==2)
        t = t+"Two "; 
        if (r==3)
        t = t+"Three "; 
        if (r==4)
        t = t+"Four "; 
        if (r==5)
        t = t+"Five "; 
        if (r==6)
        t = t+"Six "; 
        if (r==7)
        t = t+"Seven "; 
        if (r==8)
        t = t+"Eight "; 
        if (r==9)
        t = t+"Nine "; 
        x = parseInt(x/10);
        }
        document.getElementById("t2").value = t;  
        }
        }
        </script>
   </body> 
   </html>


OUTPUT

case1

First HTML Page-week 2


CASE2

First HTML Page-week 2



CASE3

First HTML Page-week 2


Comments

Popular posts from this blog

Bit Stuffing Program

#include<stdio.h> main() { int i,j,k,n,count=0; int a[30],b[30]; printf("The flag is 01111110"); printf("\n Enter the message size:"); scanf("%d",&n); printf("\n Enter the message in bits(0/1):"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("\n The message is:"); for(i=0;i<n;i++) { printf("%d",a[i]); } printf("\n"); for(i=0,j=0;i<n;i++,j++) { if(a[i]==1) { if(count==5) { b[j]=0; j++; count=0; } else count++; b[j]=a[i]; } k=j; printf("\n The coded message is:"); printf("01111110 /t"); for(j=0;j<k;j++) { printf("%d",b[j]); } printf("\01111110\n"); count=0; printf("The encoded message is :\n"); printf("\n 01111110 \t"); for(i=0;i<k;i++) { if(b[i]==1 && count<5) { printf("%d",b[i]...

CPU Schedueling programs

        Fcfs program         #include<stdio.h> #include<conio.h> main() { int bt[20], wt[20], tat[20], i, n; float wtavg, tatavg; printf("\nEnter the number of processes -- "); scanf("%d", &n); for(i=0;i<n;i++) { printf("\nEnter Burst Time for Process %d -- ", i); scanf("%d", &bt[i]); } wt[0] = wtavg = 0; tat[0] = tatavg = bt[0]; for(i=1;i<n;i++) { wt[i] = wt[i-1] +bt[i-1]; tat[i] = tat[i-1] +bt[i]; wtavg = wtavg + wt[i]; tatavg = tatavg + tat[i]; } printf("\t PROCESS \tBURST TIME \t WAITING TIME\t TURNAROUND TIME\n"); for(i=0;i<n;i++) printf("\n\t P%d \t\t %d \t\t %d \t\t %d", i, bt[i], wt[i], tat[i]); printf("\nAverage Waiting Time -- %f", wtavg/n); printf("\nAverage Turnaround Time -- %f", tatavg/n); getch(); } Output SJF program #include<stdio.h> #include<conio.h> main() { int p[20], bt[20], wt[20],...