Ticker

10/recent/ticker-posts

Header Ads Widget

Total Aurface Area Calculator Source Code

The total surface area of a solid shape is the sum of the areas of all its surfaces. It includes the area of all the faces, including the base(s) and any lateral faces. For common solid shapes: 

 1. Cube: Total surface area = 6 (side length)2

2. Rectangular Prism: 
 Total surface area = 2 (length x width + width x height + height x length) 

 3. Sphere: Total surface area = 4  π  (radius)2
 
 4. Cylinder:
    Total surface area 
                   = 2  π radius (height) + 2  π (radius)2 

 5. Cone: 
          Total surface area 
         = π * radius * (slant height) + π * (radius)2

6. Pyramid: 
       Total surface area 
            = Sum of areas of all lateral faces + area of base 

 These are just a few examples, but the concept applies to any three-dimensional shape. The total surface area helps in understanding the amount of material required to cover or build the object, which is crucial in various engineering, construction, and manufacturing applications.

Total Aurface Area Calculator






Total Surface Area: 0.00

Total Aurface Area Calculator Source Code

Here is the simplified source code of total surface area calculator 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Volume Calculator</title>
  <script>
    function showFields() {
      var shape = document.getElementById("shape").value;
      var inputFields = document.getElementById("inputFields");
      var fieldsHTML = "";
      switch (shape) {
        case "sphere":
          fieldsHTML = "<label for='radius'>Radius:</label><input type='number' id='radius'>";
          break;
        case "cylinder":
          fieldsHTML = "<label for='radiusCylinder'>Radius:</label><input type='number' id='radiusCylinder'>" +
                        "<br><label for='heightCylinder'>Height:</label><input type='number' id='heightCylinder'>";
          break;
        case "cone":
          fieldsHTML = "<label for='radiusCone'>Radius:</label><input type='number' id='radiusCone'>" +
                        "<br><label for='heightCone'>Height:</label><input type='number' id='heightCone'>";
          break;
        case "cube":
          fieldsHTML = "<label for='sideCube'>Side length:</label><input type='number' id='sideCube'>";
          break;
        case "cuboid":
          fieldsHTML = "<label for='lengthCuboid'>Length:</label><input type='number' id='lengthCuboid'>" +
                        "<br><label for='widthCuboid'>Width:</label><input type='number' id='widthCuboid'>" +
                        "<br><label for='heightCuboid'>Height:</label><input type='number' id='heightCuboid'>";
          break;
          case "hsphere":
          fieldsHTML = "<label for='radius'>Radius:</label><input type='number' id='radius'>";
          break;
        default:
          fieldsHTML = "";
      }
      inputFields.innerHTML = fieldsHTML;
    }

    function calculateVolume() {
      var shape = document.getElementById("shape").value;
      var result = document.getElementById("result");
      var output;

      switch (shape) {
        case "sphere":
          var radius = parseFloat(document.getElementById("radius").value);
          output = 4 * Math.PI * Math.pow(radius, 2);
          break;
        case "cylinder":
          var radiusCylinder = parseFloat(document.getElementById("radiusCylinder").value);
          var heightCylinder = parseFloat(document.getElementById("heightCylinder").value);
          output = 2 * Math.PI * Math.pow(radiusCylinder, 1) * (heightCylinder + radiusCylinder);
          break;
        case "cone":
          var radiusCone = parseFloat(document.getElementById("radiusCone").value);
          var heightCone = parseFloat(document.getElementById("heightCone").value);
          output = Math.PI * Math.pow(radiusCone, 1) * (heightCone + radiusCone);
          break;
        case "cube":
          var sideCube = parseFloat(document.getElementById("sideCube").value);
          output = 6 * Math.pow(sideCube, 2);
          break;
        case "cuboid":
          var lengthCuboid = parseFloat(document.getElementById("lengthCuboid").value);
          var widthCuboid = parseFloat(document.getElementById("widthCuboid").value);
          var heightCuboid = parseFloat(document.getElementById("heightCuboid").value);
          output = 2 * heightCuboid * (lengthCuboid + widthCuboid) + ( 2 * lengthCuboid * widthCuboid);
          break;
          case "hsphere":
          var radius = parseFloat(document.getElementById("radius").value);
          output = 3 * Math.PI * Math.pow(radius, 2);
          break;
        default:
          output = "Invalid selection";
      }

      result.textContent = "Total Surface Area: " + output.toFixed(2);
    }
  </script>
  <style>
  label{
      
  }
  input[type=number]{
      margin:5px;
      text-align:center;
      border:2px solid blue;
      font-size:18px;
      border-radius:6px;
      display:inlinebblock;
  }
  #shape {
      display:block;
      border:2px solid red;
      font-size:18px;
      border-radius:6px;
      margin:10px auto;
      width:70%;
      text-align:center;
      padding:4px;
  }
  #calc-vol{
      margin:10px auto;
      width:70%;
      font-size:18px;
      color:#fff;
      background:red;
      font-weight:800;
      border:1px solid red;
      border-radius:8px;
      padding:5px;
     
  }
  </style>
</head>
<body>
<div style="background:lightblue;padding:10px;text-align:center;">
  <h2>Total Aurface Area Calculator</h2>

  <label for="shape">Select a shape:</label>
  <select id="shape" onchange="showFields()">
    <option value="select">Select</option>
    <option value="sphere">Sphere</option>
    <option value="cylinder">Cylinder</option>
    <option value="cone">Cone</option>
    <option value="cube">Cube</option>
    <option value="cuboid">Cuboid</option>
    <option value="hsphere">Hemi Sphere</option>
  </select>
  <br><br>
  <div id="inputFields"></div>
  <br>
  <button id ="calc-vol" onclick="calculateVolume()">Calculate</button>
  <br><br>
  <div id="result">Total Surface Area: 0.00</div>
  </div>
</body>
</html>

Post a Comment

0 Comments