Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 3
Help,pls.
You are writing a program to calculate the area of a rectangle. Currently it takes the the length and the height as inputs. Complete the given method to take them as arguments, then calculate and return the area. Sample Input 4 5 Sample Output 20 Code: using System; using System.Formats.Asn1; namespace площадь_прямоугольника { class Program { static void Main(string[] args) { int lenght = Convert.ToInt32(Console.ReadLine()); int height = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Area(lenght,height)); } static int Area(int lenght, int height) { Console.WriteLine(length*height); return length*height; } } }
8 Answers
+ 4
Remove;
Console.WriteLine(lenght*height);
From the Area method and just return the value.
P.S. it is spelled length not lenght
+ 1
Thnx a lot)
+ 1
Thanks for the awesome information.
+ 1
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int length = Convert.ToInt32(Console.ReadLine());
int height = Convert.ToInt32(Console.ReadLine());
//Output
Console.WriteLine (Area(length , height)) ;
}
//complete the method
static int Area (int length, int height)
{
return length* height ;
}
}
}
+ 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int length = Convert.ToInt32(Console.ReadLine());
int height = Convert.ToInt32(Console.ReadLine());
//Output
Console.WriteLine (Area(length , height)) ;
}
//complete the method
static int Area (int length, int height)
{
return length* height ;
}
}
}
0
Area of a Rectangle
Create a function that calculates the area of a rectangle. If the arguments are invalid, your function must return -1. Examples area(3, 4) ➞ 12 area(10, 11) ➞ 110 area(-1, 5) ➞ -1 area(0, 2) ➞ -1 Notes N/A
algebrageometrymath
Very Easy
0
The error is caused by a misspelling in the method parameter. "lenght" should be "length".
0
let width = parseInt(readLine(),10);
let length = parseInt(readLine(),10);
//Complete the function
function area(x,y){
area=length*width;
console.log(area);
}
//call the function
area();