AlexKondov

Java 2-4-8

May 6th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. package Exams;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TwoFourEight {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner input = new Scanner(System.in);
  9.         int num = input.nextInt();
  10.         int result = 0;
  11.        
  12.         int c = num % 10;
  13.         num /= 10;
  14.         int b = num % 10;
  15.         num /= 10;
  16.         int a = num % 10;
  17.         num /= 10;
  18.        
  19.         if (b == 2) {
  20.             result = a % c;
  21.         }
  22.         else if (b == 4) {
  23.             result = a + c;
  24.         }
  25.         else if (b == 8) {
  26.             result = a * c;
  27.         }
  28.        
  29.         if (result % 4 == 0) {
  30.             System.out.println(result / 4);
  31.             System.out.println(result);
  32.         }
  33.         else {
  34.             System.out.println(result % 4);
  35.             System.out.println(result);
  36.         }
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment