Advertisement
Guest User

Untitled

a guest
Dec 30th, 2023
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Game {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8. int number = scanner.nextInt();
  9.  
  10. int left = number / 100;
  11. int mid = (number / 10) % 10;
  12. int right = number % 10;
  13.  
  14. int first = left + mid + right;
  15. int second = left + mid * right;
  16. int third = left * mid * right;
  17. int fourth = left * mid + right;
  18.  
  19. int max = first;
  20.  
  21. if (second > max) {
  22. max = second;
  23. } else if (third > max) {
  24. max = third;
  25. } else if (fourth > max) {
  26. max = fourth;
  27. }
  28.  
  29. System.out.println(max);
  30.  
  31.  
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement