Gametask

mail@pastecode.io avatar
unknown
java
a year ago
1.3 kB
26
Indexable
Never
import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        // read in the three-digit number from the user
        System.out.print("Enter a three-digit number: ");
        int number = input.nextInt();

        // extract the three digits from the number
        int hundreds = number / 100;
        int tens = (number / 10) % 10;
        int ones = number % 10;

        // calculate the maximum value that can be obtained
        int maxResult = 0;
        int tempResult = ones * tens + hundreds;
        if (tempResult > maxResult) {
            maxResult = tempResult;
        }
        tempResult = ones * tens * hundreds;
        if (tempResult > maxResult) {
            maxResult = tempResult;
        }
        tempResult = ones + tens + hundreds;
        if (tempResult > maxResult) {
            maxResult = tempResult;
        }
        tempResult = ones + tens * hundreds;
        if (tempResult > maxResult) {
            maxResult = tempResult;
        }
        tempResult = ones * hundreds + tens;
        if (tempResult > maxResult) {
            maxResult = tempResult;

        }

        // print the maximum value
        System.out.println(maxResult);
    }
}