Advertisement
Jhonny_V

Untitled

Oct 7th, 2020
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3. public class game {
  4.  
  5.     public static void main(String[] args) {
  6.     Scanner sc = new Scanner(System.in);
  7.     int result = 0;
  8.     int N = Integer.parseInt(sc.nextLine());
  9.     int f=N/100;
  10.     int s=(N/10)%10;
  11.     int t=(N%10);
  12.  
  13.     if(s==1||s==0){ result=f+s+t;} //second = 1 or 0
  14.     else if (t==0&&f==1){result=f+s+t;} //third = 0 first =1
  15.     else if (t==0&&f!=1){result=f*s+t;} //third = 0
  16.     else if (t==1&&f==1){result=f+s+t;} //third = 1 first =1
  17.     else if (t==1&&f!=1){result=f*s+t;} //third = 1
  18.     else if (f==1||f==0){result=f+s*t;}
  19.  
  20.     else{result=f*s*t;}
  21.     System.out.println(result);
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement