You are on page 1of 2

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