Advertisement
Zh_Zhivkov

Task_Game_Mock_Exam_Variant_2

Jul 16th, 2019
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Scanner;
  4.  
  5. public class Game {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner userInput = new Scanner(System.in);
  10.  
  11.         List<Integer> myList = new ArrayList<>(3);
  12.  
  13.         int digit = userInput.nextInt();
  14.  
  15.         while (digit > 0) {
  16.             int number = digit % 10;
  17.             digit /= 10;
  18.             myList.add(digit);
  19.         }
  20.  
  21.         int theBiggest = 0;
  22.  
  23.         theBiggest = Math.max(theBiggest, myList.get(0) + myList.get(1) + myList.get(2));
  24.         theBiggest = Math.max(theBiggest, myList.get(0) * myList.get(1) + myList.get(2));
  25.         theBiggest = Math.max(theBiggest, myList.get(0) + myList.get(1) * myList.get(2));
  26.         theBiggest = Math.max(theBiggest, myList.get(0) * myList.get(1) * myList.get(2));
  27.  
  28.         System.out.println(theBiggest);
  29.  
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement