Advertisement
svetoslavbozov

[JS] Operators and Expressions 9

Mar 13th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <title></title>
  4. <link href="styles/js-console.css" rel="stylesheet" />
  5. </head>
  6. <body>
  7.     <div id="js-console">
  8.         <div>
  9.             <label>Enter X: </label>
  10.             <input type="text" id="xCoord"/>                
  11.         </div>
  12.         <div>
  13.             <label>Enter Y: </label>
  14.             <input type="text" id="yCoord"/>                
  15.         </div>
  16.         <div>
  17.             <label>Check Position</label>
  18.             <input type="button" Value="Check" onclick="CheckPosition()"/>
  19.         </div>
  20.     </div>
  21.     <script src="scripts/js-console.js">   
  22.     </script>  
  23.     <script>
  24.         function CheckPosition() {
  25.         var x = jsConsole.readFloat("#xCoord");
  26.         var y = jsConsole.readFloat("#yCoord");
  27.  
  28.         var isInCircle = ((x - 1)*(x - 1) + (y - 1)*(y - 1) < 9 ? true : false);
  29.         var isOutRectangle = ((x > -1 && x < 5) && (y > -1 && y < 1) ? false : true);
  30.            
  31.         jsConsole.writeLine("The point" + (isInCircle && isOutRectangle ? " IS" : " IS NOT") +
  32.         " within the circle K( (1,1), 3) and out of the rectangle R(top=1, left=-1, width=6, height=2).");
  33.            
  34.         }  
  35. </script>  
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement