Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need some help implementing this in java using net beans. can anyone help A re

ID: 657668 • Letter: I

Question

I need some help implementing this in java using net beans. can anyone help

A recursive method called triangle that will display a triangle made of asterisks. The only parameter is an integer that determines the number of asterisks to print on the current line. For example, if the test call to this method is triangle(5), the output should look like: A recursive method called powerOfTen that will find and return 10m for any integer n (n is the parameter). The method should return a double value. Examples: powerOfTen(3) should return: powerOfTen(-3) should return The method should return a double. A recursive method called reverseString that will accept a string parameter. The method should print the letters of that string parameter in a reversed order (i.e., reversing the entire string). Example: reverseString("APPLE") should print:

Explanation / Answer

Answer:

Program:

1)

import java.util.*;

import java.io.*;

import java.lang.*;

public class tri{

class Triangle{

public static void triangle(int n){

public static void main(String args[])//main function

{

if(n > 0) {

      triangle(n-1);

      for(int i = 0; i < n; i++) {

        System.out.print("*");

      }

      System.out.println("");

    }

}

}

}

2)

import java.util.Scanner;

class Power1

{

    public static double power(double base_num, double base_num_pow)

    {

        

        if(base_num_pow==0)

        {

            return 1;

        }

        else if(base_num_pow==1)

        {

            return base_num;

        }

        else if(base_num_pow>1)

        {

            return base_num*power(base_num,base_num_pow-1);

        }

        else

        {

              return 1/power(base_num, -1 * base_num_pow);

        }

       

       

    }

    

}

//main class

public class tri1 {

    public static void main(String[] args)//main function

    {

      Scanner input = new Scanner(System.in);

      System.out.print("Enter the base_num number: ");

      double base_num = input.nextInt();

      System.out.print("Enter the base_num power: ");

      double base_num_pow = input.nextInt();

      

      Power access = new Power();

      

System.out.print(base + " to the power of " + base_num_pow + " is: " + access.power(base_num, base_num_pow));

    }

}

3)

package reverse_string_in_java;//package

import java.util.Scanner;

public class reverse//class declarations

{

    public static void main(String[] args)

    {

       Scanner input = new Scanner(System.in);

       System.out.print("String: ");

       String string = input.nextLine();

       System.out.println("Reverse order String: ");

       for(int i=1; i<=string.length() ;i++)

       {

            System.out.print(string.charAt(string.length()-i));

       }

       System.out.println();

    }

}