j_U1p5.java

import java.util.Scanner; class prog5 { void area(int l) { int area; area=l*l; System.out.println("area of square="+area); } void area(int l, int b) { int area; area=l*b; System.out.println("area of rectangle="+area); } public static void main(String args[]) { int l,b,s,r; Scanner sc=new Scanner(System.in); System.out.println("enter the length:"); l=sc.nextInt(); System.out.println("enter the breadth"); b=sc.nextInt(); prog5 a= new prog5(); a.area(l); a.area(l,b); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.