Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help for the following hw problem. It just needs problem solving process done for this code. *Attached is an overview of problem solving process

Need help for the following hw problem. It just needs problem solving process done for this code. *Attached is an overview of problem solving process and problem explanation** Has to be in that format!! Please due tonight!!
code:
import java.util.Scanner;
public class RecFunctions {
public static double fn1(int n){
if(n == 1){
return 1;
}
else{
return (1.0 / n) + fn1(n - 1);
}
}
public static void fn2(int n, int c){
if(n == 0){
return;
}
else{
for(int i = n - 1; i
System.out.print("*");
}
System.out.println();
fn2(n - 1, c);
for(int i = n - 1; i
System.out.print("*");
}
System.out.println();
}
}
public static void fn2(int n){
fn2(n, n);
}
public static void main(String args[]){
Scanner in = new Scanner(System.in);
System.out.print("Enter value of n for function One: ");
int n = in.nextInt();
System.out.printf("Result of function 1 is %.3f ", fn1(n));
System.out.print("Enter value of n for function Two: ");
n = in.nextInt();
System.out.println("Executing Function Two ");
fn2(n);
}
}
image text in transcribed
image text in transcribed
image text in transcribed
Problem1. (20 points) Recursive Coding Problem. Using the Problem Solving Process. Write a Java application that implements these two functions using recursive methods a. First Recursive Function. When one passes an integer as input (n for example), the return should return (output) the sum as follows: Example If the function's argument is 4, the function should return the value of 2.083 which is the sum of: 1 1/2 1/3 1/4. am This application will calculate the solution for the following function: Please enter an integer: 4 x= 1 + 1/2 + 1/3-1/4-2.083. Constraint: Must implement recursively. b. Second Recursive Function. The second function when you pass it an integer (n for example) is supposed to print lines of asterisks in the following format: 8 8 *N 9N

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

3. Influencing people to willingly follow that direction?

Answered: 1 week ago