import java.io.*;
import java.util.*;
public class Rectangle{
Scanner scan=new Scanner(System.in);
int l, b, area;
public void input()throws IOException{
System.out.println("Enter the value of L and B: ");
l=scan.nextInt();
b=scan.nextInt();
}
public void compute(){
area=l*b;
}
public void display(){
System.out.println("Length: "+l+"\nBreadth: "+b+"\nArea: "+area);
}
public static void main(String[] args)throws IOException{
Rectangle obj=new Rectangle();
obj.input();
obj.compute();
obj.display();
}
}
In above program, "\n" is used. It's an escape sequence character. "\n" means new line.
import java.util.*;
public class Rectangle{
Scanner scan=new Scanner(System.in);
int l, b, area;
public void input()throws IOException{
System.out.println("Enter the value of L and B: ");
l=scan.nextInt();
b=scan.nextInt();
}
public void compute(){
area=l*b;
}
public void display(){
System.out.println("Length: "+l+"\nBreadth: "+b+"\nArea: "+area);
}
public static void main(String[] args)throws IOException{
Rectangle obj=new Rectangle();
obj.input();
obj.compute();
obj.display();
}
}
In above program, "\n" is used. It's an escape sequence character. "\n" means new line.
Comments