0% found this document useful (0 votes)
129 views2 pages

JPR Practical Assignment 15 Solution

The document describes a Java program that demonstrates using import static. It defines a SimpleInterest class with a static interest rate variable under a customer package. It then imports the SimpleInterest class and extends it to make a class that gets user input for principal, years, and interest rate and calculates simple interest. The main method creates an instance of this class and calls its display method.

Uploaded by

sakshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views2 pages

JPR Practical Assignment 15 Solution

The document describes a Java program that demonstrates using import static. It defines a SimpleInterest class with a static interest rate variable under a customer package. It then imports the SimpleInterest class and extends it to make a class that gets user input for principal, years, and interest rate and calculates simple interest. The main method creates an instance of this class and calls its display method.

Uploaded by

sakshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. Write a java program to demonstrate use of import static.

Use static variable r (rate of


interest) under class SimpleInterest under customer package.

package customer;

import java.io.*;

public class si

{ protected static float r,p,n;

public void result() throws Exception

{ DataInputStream d=new DataInputStream(System.in);

System.out.println("Enter Principal amount : ");

p=Float.parseFloat(d.readLine());

System.out.println("Enter number of years : ");

n=Float.parseFloat(d.readLine());

import customer.si;

import java.io.*;

class c extends si

{ public void display() throws Exception

{ DataInputStream d=new DataInputStream(System.in);

result();

System.out.println("Enter rate of interest : ");

r=Float.parseFloat(d.readLine());

float s=(p*n*r)/100;

System.out.println("\nSimple Interest is : "+s);

import java.io.*;

class a4

{ public static void main(String args[]) throws Exception

{ DataInputStream d=new DataInputStream(System.in);


c ob=new c();

ob.display();

 Output :

You might also like