Java Saved Program: beautiful-life

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

/* Name of the class has to be "Script" only */
class Script
{
	public static void main (String[] args)
	{
	    Scanner s = new Scanner(System.in);
	    int num;
	    int i;
	    int digit;
	    int largest=0;
	    int small=0;
	    int multiply=1;
	    System.out.println("Upisite troznamenkasti broj");
	    do
	    {
	        num=s.nextInt();
	    }
	    while(num<100||num>999);
	    for(i=0; i<=2; i++)
	    {
	        digit=num%10;
	        if(digit>largest)
	        {
	            largest=digit;
	        }
	        num/=10;
	             
	    }
	    for(i=0; i<=2; i++)
	    {
	        digit=num%10;
	        if(digit<largest)
	        {
	            multiply*=digit;
	            System.out.println(digit);
	            System.out.println(largest);
	            System.out.println(multiply);
	        }
	        else{};
	        num/=10;
	    }
	    
	    System.out.println("Najveca znamenka je: " + largest + ", a umnozak manje dvije je: " + multiply);
	}
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs