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

This method takes two integers arguments and returns a single value. Pseudo-code

ID: 3654514 • Letter: T

Question

This method takes two integers arguments and returns a single value. Pseudo-code for computing the GCD (greatest common divisor) between two numbers is as follows: god(m,n) a = m b = n r = a modulus b a = b b= c c = a and b and while return n palindrome: Tins method takes a single String argument and returns a Boolean value If the string argument is a palindrome (the same forwards and backwards - radar, did sibohpbobia1) return true, otherwise return false There are many ways to do this. factorial: This method takes a single integer argument (say n a single integer. Using for loop to compete the factorial of a . Return the computed factorial Recall: n! = 1 times 2 times 3 times ... times n This method takes a signal integer argument (say n) and returns a signal double value. Once you have completed your factorial function. Use it to compute of the mathematic constants E2 according to the following formula. Use a for loop that times and the factors to produce your e-estimate. Try this paper - the value of your e-estimate will increase in accuracy for a higher value of n (the argument passed into your function and used by your loop). Finally write a main () method that prompts the user to enter inputs appropriate for your methods. Remember to do all input and output in your main () method pass the input to your methods and collect the result using argument statements. You don't need to do any input checking. Assume the user enter appropriate values. I suggest you your methods one at a time. You can get your marks for the method that work.

Explanation / Answer

import java.util.Scanner; public class Estimate { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter 2 number to find GCD"); System.out.println("Number 1: "); int number1 = input.nextInt(); System.out.println("Number 2 :"); int number2 = input.nextInt(); System.out.printf("GCD of %d and %d is %d ", number1,number2, GCD(number1, number2)); input.nextLine(); System.out.println("Enter a string to find if it's palindrome"); String sentence = input.nextLine(); System.out.printf("%s is palindrome ? %b ",sentence,palindrome(sentence)); System.out.println("Enter a number to find factorial"); int fact = input.nextInt(); System.out.printf("%d! = %d ",fact,factorial(fact)); System.out.println("Enter a number to find e Estimate"); int n = input.nextInt(); System.out.printf("'e' Estimate (upto %d) = %f ",n,eEstimate(n)); } public static int GCD(int m, int n) { int a = m; int b = n; int r = a%b; while(r != 0) { a = b; b = r; r = a%b; } return b; } public static boolean palindrome(String sentence) { int start = 0; int end = sentence.length()-1; while(start
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote