stoychevamaria89

Untitled

Apr 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Game2 {
  3. public static void main(String[] args){
  4. Scanner scanner = new Scanner(System.in);
  5. int N = scanner.nextInt();
  6.  
  7. int[] intTab = String.valueOf(N).chars().map(Character::getNumericValue).toArray();
  8. int i = 0;
  9. int sumOfFirstTwo = intTab[0] + intTab[1] * intTab [2];
  10. int sumOfSecondTwo = intTab[0] * intTab[1] + intTab [2];
  11. int sumOfThidTwo = intTab[0] + intTab[1] + intTab [2];
  12. int sumOfFourthTwo = intTab[0] * intTab[1] * intTab [2];
  13. if(Math.max(sumOfFirstTwo,sumOfSecondTwo) > Math.max(sumOfThidTwo,sumOfFourthTwo)){
  14. System.out.print(Math.max(sumOfFirstTwo,sumOfSecondTwo));
  15. }
  16. else {
  17. System.out.print(Math.max(sumOfThidTwo,sumOfFourthTwo));
  18. }
  19.  
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment