Advertisement
Venciity

[Java] 2-4-8

May 6th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. //http://bgcoder.com/Contests/107/Telerik-Academy-Exam-1-6-December-2013-Evening
  2. import java.util.Scanner;
  3.  
  4. public class twoFourEight {
  5.  
  6.     @SuppressWarnings("resource")
  7.     public static void main(String[] args) {
  8.        
  9.         double a = new Scanner(System.in).nextDouble();
  10.         double b = new Scanner(System.in).nextDouble();
  11.         double c = new Scanner(System.in).nextDouble();
  12.        
  13.         double result = 0;
  14.        
  15.         if (b == 2)
  16.         {
  17.             result = a % c;
  18.         }
  19.         if (b == 4)
  20.         {
  21.             result = a + c;
  22.         }
  23.         if (b == 8)
  24.         {
  25.             result = a * c;
  26.         }
  27.        
  28.         double remainder = result % 4;
  29.        
  30.         if (remainder == 0)
  31.         {
  32.             System.out.println((int)result / 4);
  33.         }
  34.         else
  35.         {
  36.             System.out.println((int)remainder);
  37.         }
  38.  
  39.         System.out.println((int)result);
  40.  
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement