Advertisement
RokiAdhytama

Analysis - Chapter 8

Jul 2nd, 2022
939
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.19 KB | None
  1. <html xmlns = "http://www.w3.org/1999/xhtml">
  2.    <head>
  3.       <title>Analysis of Examination Results</title>
  4.  
  5.       <script type = "text/javascript">
  6.          <!--
  7.          // initializing variables in declarations
  8.          var passes = 0,      // number of passes
  9.              failures = 0,    // number of failures
  10.              student = 1,     // student counter
  11.              result;          // one exam result
  12.  
  13.          // process 10 students; counter-controlled loop
  14.          while ( student <= 10 ) {
  15.             result = window.prompt(
  16.                   "Enter result (1=pass,2=fail)", "0" );
  17.  
  18.             if ( result == "1" )
  19.                passes = passes + 1;
  20.             else
  21.                failures = failures + 1;
  22.  
  23.             student = student + 1;
  24.          }
  25.  
  26.          // termination phase
  27.          document.writeln( "<h1>Examination Results</h1>" );
  28.          document.writeln(
  29.             "Passed: " + passes + "<br />Failed: " + failures );
  30.  
  31.          if ( passes > 8 )
  32.             document.writeln( "<br />Raise Tuition" );
  33.          // -->
  34.       </script>
  35.  
  36.    </head>
  37.    <body>
  38.       <p>Click Refresh (or Reload) to run the script again</p>
  39.    </body>
  40. </html>
Advertisement
RAW Paste Data Copied
Advertisement