Question: I've been working on this problem and i can't seem to find out what's wrong with my code. Here's the exercise: Create an Android app
I've been working on this problem and i can't seem to find out what's wrong with my code.
Here's the exercise:
Create an Android app that displays the area and circumference for rectangles. Create a Rectangle class that performs the calculations, and instantiate a Rectangle object in the main activity based on user-entered length and width values.
function Rectangle(double length, double width){
this.length = length; this.width = width; this.area = getArea; this.perimeter = getPerimeter; function double getArea(){ return this.length * this.width; } function double getPerimeter(){ return 2 * (this.length + this.width); } } function showData(){ var len = parseFloat(document.getElementById('length').value); if(isNaN(len)){ document.getElementById('display').innerHTML = 'Please enter numbers only'; } else { if(len<0) len*= -1; var myRectangle = new Rectangle(len); var msg = "Area: " + myRectangle.area() + " Perimeter: " + myRectangle.perimeter(); document.getElementById('display').innerHTML = msg; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
