Untitled
unknown
java
3 years ago
1.1 kB
56
Indexable
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
int maxResult = Integer.MIN_VALUE;
int hundreds = num / 100;
int tens = (num / 10) % 10;
int ones = num % 10;
// Multiplying two digits and adding the third digit
int tempResult = tens * ones + hundreds;
if (tempResult > maxResult) {
maxResult = tempResult;
}
// Adding two digits and multiplying the third digit
tempResult = tens + ones * hundreds;
if (tempResult > maxResult) {
maxResult = tempResult;
}
// Multiplying all three digits
tempResult = ones * tens * hundreds;
if (tempResult > maxResult) {
maxResult = tempResult;
}
// Adding all three digits
tempResult = ones + tens + hundreds;
if (tempResult > maxResult) {
maxResult = tempResult;
}
System.out.println(maxResult);
}
}Editor is loading...