package src; public class Lab7 { public static void main(String[] args) { // Call your methods here } /** * Part 1 - Writing simple geometric functions */ /** * Part 1a - Write a function called...

I dont know hoe to do this



package src; public class Lab7 { public static void main(String[] args) { // Call your methods here } /** * Part 1 - Writing simple geometric functions */ /** * Part 1a - Write a function called areaOfCircle() * * It should take one argument - the radius r as a double * * It should return the area of a circle with radius r (as a double) * The area of a circle is pi*(r^2) * * Pi can be found in the Math class. * */ /** * Part 1b - Write a function called volumeOfCone() * * It should take two arguments (both doubles): * - The radius r * - The height h * * It should return the volume of a cone with radius r and height h (as a double) * The volume of a cone is pi*(r^2)*(h/3) * */ /** * Part 2- Recursive Factorial * Write a function called factorial() * * In the lab about loops, you implemented a factorial function * using a loop. Now, you will implement the same function * using recursion. * * Remeber, every recursive function has two parts: * 1. The base case * if (base-case-condition) { * return * } * 2. The recursive case * - The value you return should involve a call to the * same function, but CHANGE THE ARGUMENTS * * Your function should have one argument: an integer n * It should return an integer representing n-factorial (n!) * * HINT: Remeber that n! = n * (n-1)! * HINT: 0! = 1 * * Please note that your solution will be marked incorrect * if you use loops, despite passing any GradeScope tests. * You are meant to practice recursion with this problem. */ /** *Part 3- Write simple string functions * * Part 3a - Write a function called repeat() * * It should take two arguments: * - A String s * - An int num * * It should return the string added to itself as many times as the num says. * For example: s = "hello" and num = 3 * It should return "hellohellohellohello" */ /** * Part 3b - Write a function called findchar() * * It should take two arguments: * - A String s * - An int index * * It should return the char at the given index. * For example: s = "hello" and index = 3 * It should return 'l' */ /** *Part 4 - Fibonacci * * Write a function called fibonacci() * * It should take one argument: int num * * It should print out num amount of the fibonacci sequence. * A Fibonacci sequence starts with 0 and 1, then adds all the two previous numbers * together to get the next number. So for example, if num = 5 it should print out * the first 5 numbers of the Fibonacci sequence, would look like this: * "0 1 1 2 3" */ }
Feb 24, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here