Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me to solve this JavaScript problem using Notepad++ Thank You. Area Calculator This program calculates the area of a rectangle and a triangle.

Please help me to solve this JavaScript problem using Notepad++

Thank You.

image text in transcribedimage text in transcribed

Area Calculator This program calculates the area of a rectangle and a triangle. Create three textboxes and two buttons in your HTML file. Similar codes can be found in the Chapter 4 presentation. Allow the user to enter a value for the height and one for the base/width. Then if you click the "Rectangle" button, the area of a rectangle will be displayed in the last textbox. If the user clicks the "Triangle" button, the area of a triangle is displayed As you see, the same textboxes are used for both shapes. Therefore, when you display the area, indicate if it is the area of a triangle or a rectangle (see the images) Area Calculator Area Calculator 10 Height Base/Width 20 Area 10 Height Base/Width 20 Area Rectangle: 200 Triangle: 100 Rectanglegle Rectangle Triangle Requirements D Create an HTML file and an external JavaScript file D Add your name to the name of both file (for example, JohnSmith_Lab4.html) D Use comments to add the following information inside your JavaScript 1. Author's name 2. Date 3. Purpose of the program Add more comments as needed D Create four functions in your script 1. calcRectangle Area0 Gets the values from the screen. It calculates the area of the rectangle, and RETURNS a value. 2. displayRectangle Area0 Calls calcRectangle Area0. Then, it displays the value on the screern. 3. calcTriangleArea Gets the values from the screen. It calculates the area of the triangle, and RETURNS a value. 4. displayTriangleArea0 Calls calcTriangle Area). Then, it displays the value on the screen. D Please pay attention to all bold RETURN words D Add comments for each function to explain what it does D Do not use any global variables, All variables must be local D You must follow naming conventions This might help 1. Use asterisk (*) as multiplication operator 2. Use slash (/) as division operator 3. This line of code in JavaScript gets the value from the textbox on the screen. The parseFloatO function converts the value to a floating point type height-parseFloat (frmCalculator ttHeight value): height is a variable name. frmCalculator is the name of the form I created in HTML. txthleight is the name of the textbox I created 4. This line of code adds the value to the screen: frmCalculator ttAreavalue "Rectangle: "+ area

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions