{"id":1529,"date":"2016-07-25T03:48:20","date_gmt":"2016-07-25T03:48:20","guid":{"rendered":"http:\/\/javascript-tutor.net\/?p=1529"},"modified":"2017-09-21T13:34:31","modified_gmt":"2017-09-21T13:34:31","slug":"creating-math-drill-calculating-volume-cuboid","status":"publish","type":"post","link":"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/","title":{"rendered":"Creating a math drill for calculating volume of a cuboid"},"content":{"rendered":"<p>We have learned how to create a calculator that calculates the volume of a cuboid. Using the similar script, we can write a JavaScript that allows the user to input the dimensions as well as\u00a0\u00a0enter the answer. If the answer is wrong, it will displays the &#8220;Incorrect&#8221; message, otherwise it will show the &#8220;Correct&#8221; message.<\/p>\n<p>The JavaScript is as follows:&#8217;<\/p>\n<p>function Calvol(width, length, height){<br \/>\nvar vol=width*length*height;<br \/>\nreturn vol;<br \/>\n}<br \/>\nfunction CalSize(){<br \/>\nvar x=parseInt(document.getElementById(&#8220;wdt&#8221;).value);<br \/>\nvar y=parseInt(document.getElementById(&#8220;lgt&#8221;).value);<br \/>\nvar z=parseInt(document.getElementById(&#8220;hgt&#8221;).value);<br \/>\nvar Size=Calvol(x,y,z);<br \/>\nvar answer=document.getElementById(&#8216;ans1&#8217;).value;<br \/>\nif (answer==Size)<br \/>\n{message=&#8221;Correct&#8221;;}<\/p>\n<p>else<br \/>\n{message=&#8221;Incorrect, try again&#8221;;}<\/p>\n<p>document.getElementById(&#8216;ans&#8217;).textContent=message;<\/p>\n<p>}<\/p>\n<p>And the html is as follows:<\/p>\n<p>&lt;!DOCTYPE html&gt;<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=windows-1252&#8243;&gt;<br \/>\n&lt;title&gt;Volume Calculation&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body onload=&#8221;RandomFn()&#8221;&gt;<br \/>\n&lt;h1&gt;Volume of a Cuboid&lt;\/h1&gt;<br \/>\n&lt;p&gt;Width&amp;nbsp;=&amp;nbsp;&amp;nbsp;&lt;input type=&#8221;text&#8221; size=&#8221;5&#8243; id=&#8221;wdt&#8221;&gt;&lt;\/p&gt;<br \/>\n&lt;p&gt;Length=&amp;nbsp;&lt;input type=&#8221;text&#8221; size=&#8221;5&#8243; id=&#8221;lgt&#8221;&gt;&lt;\/p&gt;<br \/>\n&lt;p&gt;Height=&amp;nbsp;&lt;input type=&#8221;text&#8221; size=&#8221;5&#8243; id=&#8221;hgt&#8221;&gt;&lt;\/p&gt;<\/p>\n<p>&lt;h3&gt;The Volume is&lt;\/h3&gt;<\/p>\n<p>&lt;input type=&#8221;text&#8221; size=&#8221;5&#8243; id=&#8221;ans1&#8243;&gt;&lt;br&gt;&lt;br&gt;<br \/>\n&lt;h3 id=&#8221;ans&#8221;&gt;&lt;h3&gt;<br \/>\n&lt;script&gt;<br \/>\nfunction Nextq() {<br \/>\nlocation.reload();<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&lt;input type=&#8221;button&#8221; value=&#8221;Check Answer&#8221; onclick=&#8221;CalSize()&#8221;&gt;&lt;br&gt;&lt;br&gt;<br \/>\n&lt;input type=&#8221;button&#8221; value=&#8221;Next Question&#8221; onclick=&#8221; location.reload();&#8221;&gt;<br \/>\n&lt;script&gt;<br \/>\nfunction RandomFn() {<br \/>\ndocument.getElementById(&#8220;wdt&#8221;).innerHTML = parseInt(Math.random()*9+1);<br \/>\ndocument.getElementById(&#8220;lgt&#8221;).innerHTML = parseInt(Math.random()*9+1);<br \/>\ndocument.getElementById(&#8220;hgt&#8221;).innerHTML = parseInt(Math.random()*9+1);<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;volume2.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p>Click <a href=\"http:\/\/javascript-tutor.net\/jsample\/volume2.html\">Here<\/a> to run the script.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have learned how to create a calculator that calculates the volume of a cuboid. Using the similar script, we can write a JavaScript that allows the user to input the dimensions as well as\u00a0\u00a0enter the answer. If the answer is wrong, it will displays the &#8220;Incorrect&#8221; message, otherwise it will show the &#8220;Correct&#8221; message. &hellip; <a href=\"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Creating a math drill for calculating volume of a cuboid&#8221;<\/span><\/a><\/p>\n","protected":false},"author":35895,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1529","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Creating a math drill for calculating volume of a cuboid - Learn JavaScript Online | Free Interactive JavaScript Tutorials<\/title>\n<meta name=\"description\" content=\"Learn how to create a JavaScript to calculate volume\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating a math drill for calculating volume of a cuboid - Learn JavaScript Online | Free Interactive JavaScript Tutorials\" \/>\n<meta property=\"og:description\" content=\"Learn how to create a JavaScript to calculate volume\" \/>\n<meta property=\"og:url\" content=\"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn JavaScript Online | Free Interactive JavaScript Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-25T03:48:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-09-21T13:34:31+00:00\" \/>\n<meta name=\"author\" content=\"Liew Voon Kiong\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Liew Voon Kiong\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/\",\"url\":\"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/\",\"name\":\"Creating a math drill for calculating volume of a cuboid - Learn JavaScript Online | Free Interactive JavaScript Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/javascript-tutor.net\/#website\"},\"datePublished\":\"2016-07-25T03:48:20+00:00\",\"dateModified\":\"2017-09-21T13:34:31+00:00\",\"author\":{\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8\"},\"description\":\"Learn how to create a JavaScript to calculate volume\",\"breadcrumb\":{\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/javascript-tutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating a math drill for calculating volume of a cuboid\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/javascript-tutor.net\/#website\",\"url\":\"https:\/\/javascript-tutor.net\/\",\"name\":\"Learn JavaScript Online | Free Interactive JavaScript Tutorials\",\"description\":\"Master JavaScript with free, interactive tutorials for beginners and experienced coders. Practice live coding and visualize how JavaScript works step by step.\",\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8\",\"name\":\"Liew Voon Kiong\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g\",\"caption\":\"Liew Voon Kiong\"},\"url\":\"https:\/\/javascript-tutor.net\/index.php\/author\/ajt7051jct\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating a math drill for calculating volume of a cuboid - Learn JavaScript Online | Free Interactive JavaScript Tutorials","description":"Learn how to create a JavaScript to calculate volume","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/","og_locale":"en_US","og_type":"article","og_title":"Creating a math drill for calculating volume of a cuboid - Learn JavaScript Online | Free Interactive JavaScript Tutorials","og_description":"Learn how to create a JavaScript to calculate volume","og_url":"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/","og_site_name":"Learn JavaScript Online | Free Interactive JavaScript Tutorials","article_published_time":"2016-07-25T03:48:20+00:00","article_modified_time":"2017-09-21T13:34:31+00:00","author":"Liew Voon Kiong","twitter_misc":{"Written by":"Liew Voon Kiong","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/","url":"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/","name":"Creating a math drill for calculating volume of a cuboid - Learn JavaScript Online | Free Interactive JavaScript Tutorials","isPartOf":{"@id":"https:\/\/javascript-tutor.net\/#website"},"datePublished":"2016-07-25T03:48:20+00:00","dateModified":"2017-09-21T13:34:31+00:00","author":{"@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8"},"description":"Learn how to create a JavaScript to calculate volume","breadcrumb":{"@id":"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/javascript-tutor.net\/index.php\/2016\/07\/25\/creating-math-drill-calculating-volume-cuboid\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/javascript-tutor.net\/"},{"@type":"ListItem","position":2,"name":"Creating a math drill for calculating volume of a cuboid"}]},{"@type":"WebSite","@id":"https:\/\/javascript-tutor.net\/#website","url":"https:\/\/javascript-tutor.net\/","name":"Learn JavaScript Online | Free Interactive JavaScript Tutorials","description":"Master JavaScript with free, interactive tutorials for beginners and experienced coders. Practice live coding and visualize how JavaScript works step by step.","inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8","name":"Liew Voon Kiong","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g","caption":"Liew Voon Kiong"},"url":"https:\/\/javascript-tutor.net\/index.php\/author\/ajt7051jct\/"}]}},"_links":{"self":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/1529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/users\/35895"}],"replies":[{"embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/comments?post=1529"}],"version-history":[{"count":3,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/1529\/revisions"}],"predecessor-version":[{"id":1532,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/1529\/revisions\/1532"}],"wp:attachment":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=1529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=1529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=1529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}