package class4_3_Switch; import java.util.Scanner; public class WithSwitch { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Choose an option"); System.out.println("Enter L for logarithm."); System.out.println("Enter M for maximum."); System.out.print("Enter a letter: "); String word = in.next(); char letter = word.charAt(0); double output; switch(letter) { case 'l': case 'L': System.out.println("Logarithm"); System.out.println("Enter the number to take the log of: "); double number = in.nextDouble(); System.out.println("Enter the base:"); double base = in.nextDouble(); output = Math.log(number)/Math.log(base); System.out.println("log base "+base+" of "+number+" is "+output); break; case 'm': case 'M': System.out.println("Maximum"); System.out.println("Enter the first number: "); double first = in.nextDouble(); System.out.println("Enter the second number: "); double second = in.nextDouble(); output = Math.max(first,second); System.out.println("The maximum value is: "+output); break; default: System.out.println("Unsupported"); break; } } }