Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo {
- static int getMax(int number1, int number2){
- return Math.max(number1, number2);
- }
- static char getMax(char symbol1,char symbol2){
- if ((int) symbol1 > (int) symbol2) {
- return symbol1;
- }
- return symbol2;
- }
- static String getMax(String word1,String word2){
- int word3 = word1.length();
- int word4 = word2.length();
- if(word3 > word4){
- return word1;
- }
- return word2;
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String word = scanner.nextLine();
- switch(word){
- case "int":
- int number1 = Integer.parseInt(scanner.nextLine());
- int number2 = Integer.parseInt(scanner.nextLine());
- System.out.println(getMax(number1,number2));
- break;
- case "char":
- char symbol1 = scanner.nextLine().charAt(0);
- char symbol2 = scanner.nextLine().charAt(0);
- System.out.println(getMax(symbol1,symbol2));
- break;
- case "String":
- String word1 = scanner.nextLine();
- String word2 = scanner.nextLine();
- System.out.println(getMax(word1,word2));
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement