Question
Can someone please help rewrite the below java program in two versions? One should be recursive and the other should be 'not recursive. import java.util.Scanner;
Can someone please help rewrite the below java program in two versions? One should be recursive and the other should be 'not recursive.
import java.util.Scanner;
public class FunctionDemo {
public static void main(String[] args) { Scanner in = new Scanner(System.in);
System.out.printf("Enter a string: "); String str = in.nextLine();
System.out.printf("The string you entered has %d charcters. ", str.length()); System.out.printf("The first character is: %c. ", str.charAt(0));
int value = str.charAt(0); System.out.printf("The ASCII value of this character is %d. ", value); System.out.printf("The square root of %d is %f. ", value, Math.sqrt(value));
System.out.printf("Convert the string to all upper case: %s ", str.toUpperCase()); System.out.printf("Convert the string to all lower case: %s ", str.toLowerCase());
in.close(); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started