-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.html
13 lines (13 loc) · 2.13 KB
/
task.html
1
2
3
4
5
6
7
8
9
10
11
12
13
<h2>Right triangle</h2>
<html>
<head></head>
<body>
<p>A right triangle is a triangle in which one angle is a right angle (90-degree angle). The side opposite to the right angle is called a <em>hypotenuse </em>and the other two sides are called <em>legs </em>(or <em>catheti</em>). </p>
<p>The <em>Pythagorean theorem </em>holds for right triangles with integer lengths of all sides:</p>
<p><span class="math-tex">\(c^2 = a^2 + b^2\)</span>, where <span class="math-tex">\(c\)</span> is the length of the hypotenuse, and <span class="math-tex">\(a\)</span> and <span class="math-tex">\(b\)</span> are the lengths of the legs.</p>
<p>Here's a class <code class="java">RightTriangle</code> with the class constructor. The constructor is missing the <code class="java">area</code> attribute. Calculate the area <strong>S</strong> according to this formula:</p>
<p><span class="math-tex">\(S = \frac{1}{2}ab\)</span>.</p>
<p>Three numbers ( <code class="java">input_c</code>, <code class="java">input_a</code>, and <code class="java">input_b</code>) have already been read from the input. They represent a triangle: the first number is the length of the supposed hypotenuse, the other two are the legs. If the triangle with these sides is right, create an instance of the class <code class="java">RightTriangle</code> and print its area (with one decimal). If the triangle is not right, print "<strong>Not right". </strong></p>
</body>
</html><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">5 3 4</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">6.0</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">4 3 2</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">Not right</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">13 12 5</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">30.0</code></pre><br><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<a href="https://hyperskill.org/learn/step/6669">Show topic summary</a>