Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

design an algorithm that prompts the user to enter a number in the range of 1 through 100 and validates the in?

put.

2 Answers

Relevance
  • ?
    Lv 7
    1 decade ago
    Favorite Answer

    <html>

    <body>

    <script type="text/javascript">

    var x=prompt("Enter a number between 0 and 100:","");

    try

    {

    if(x>100)

    {

    throw "Err1";

    }

    else if(x<0)

    {

    throw "Err2";

    }

    else if(isNaN(x))

    {

    throw "Err3";

    }

    }

    catch(er)

    {

    if(er=="Err1")

    {

    alert("Error! The value is too high");

    }

    if(er=="Err2")

    {

    alert("Error! The value is too low");

    }

    if(er=="Err3")

    {

    alert("Error! The value is not a number");

    }

    }

    </script>

    </body>

    </html>

  • 1 decade ago

    If you have 2 apples and sally has 3, how many apples do you have?

    Source(s): You have 2 apples.
Still have questions? Get your answers by asking now.