Define a class RecursivePower with the following specification
Class Name    RecursivePower
Data members 
int pow,k,l
Member Functions
RecursivePower() -  Constructed to initialise power= 0
void input() - to input value in k and l
intpowerof(int k , int l) Returns power of k to l recursively
void setpower()  Sets data member power=k to power l
void display   display the data member power

Also write main function
            





import java.util.*;
class Recursivepower
{
    int power,k,l;
    Recursivepower()
    {
        power=0;
        l=0;
        k=0;
    }
    void input()
    {
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the values");
        k=sc.nextInt();
        l=sc.nextInt();
    }
    int powerof(int k,int l)
    {
        if(l==0)
            return 1;
        else
            return k*powerof(k,l-1);
    }
    void setpower()
    {
        power=k;
    }
    void display()
    {
        System.out.println("Power of the number");
        int r=powerof(power,l);
        System.out.println(r);
    }
    public static void main()
    {
        Recursivepower ob=new Recursivepower();
        ob.input();
        ob.setpower();
        ob.display();
    }
}


     
                     

Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com