JPR Practical Assignment 14 Solution
JPR Practical Assignment 14 Solution
Create a user defined package “Area” with carea() & rarea() methods which will be
displaying area of circle & rectangle respectively. Write a Java program and access these
two methods here.
package area;
import java.io.*;
{ int r;
r=Integer.parseInt(d.readLine());
{ int l,b;
l=Integer.parseInt(d.readLine());
b=Integer.parseInt(d.readLine());
import area.Info;
import java.io.*;
class result1
s.carea();
s.rarea();
}
}
Output :
2. Create a user defined package “Arith” with class name as-“numbers” where read 2
numbers from user. Import above package in java program with class name as
“arithmetic” & extend above class “numbers” . Display addition, subtraction,
multiplication & division of 2 numbers.
package Arith;
import java.io.*;
n1=Integer.parseInt(d.readLine());
n2=Integer.parseInt(d.readLine());
import Arith.numbers;
import java.io.*;
in();
int a=n1+n2;
int b=n1-n2;
int c=n1*n2;
int di=n1/n2;
System.out.println("\nAddition : "+a);
System.out.println("Subtraction : "+b);
System.out.println("Multiplication : "+c);
System.out.println("Division : "+di);
import java.io.*;
class a3
a.result();
Output :