Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _09_GreaterOfTwoValues {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String type = scanner.nextLine();
- if (type.equals("int")) {
- int firstVar = Integer.parseInt(scanner.nextLine());
- int secondVar = Integer.parseInt(scanner.nextLine());
- System.out.println(getMax(firstVar, secondVar));
- } else {
- String firstVar = scanner.nextLine();
- String secondVar = scanner.nextLine();
- System.out.println(getMax(firstVar, secondVar));
- }
- }
- static int getMax(int first, int second){
- if (first >= second) {
- return first;
- }
- return second;
- }
- static char getMax(char first, char second) {
- if (first >= second){
- return first;
- }
- return second;
- }
- static String getMax(String first, String second){
- if (first.compareTo(second) >= 0) {
- return first;
- }
- return second;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement