Question

i need a simple java program that uses methods to find the area of a rectangle...

i need a simple java program that uses methods to find the area of a rectangle thank you
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
public class Main
{
static int calculateArea(int l,int b)
{
//methods takes length and width and
//returns area
return l*b;
}
   public static void main(String[] args) {
       int length,width;
       Scanner s=new Scanner(System.in);
       //read length and widths
       System.out.print("enter length of rectangle:");
       length=s.nextInt();
       System.out.print("enter width of rectangle:");
       width=s.nextInt();
       //call function
       int area=calculateArea(length,width);
       System.out.println("The Area of rectangle is "+area);
   }
}

Add a comment
Know the answer?
Add Answer to:
i need a simple java program that uses methods to find the area of a rectangle...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT