Advertisement
Venciity

[SoftUni C# exam preparation] 01.2-4-8

Apr 10th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         decimal a = Decimal.Parse(Console.ReadLine());
  8.         decimal b = Decimal.Parse(Console.ReadLine());
  9.         decimal c = Decimal.Parse(Console.ReadLine());
  10.  
  11.         decimal result = 0;
  12.  
  13.         if (b == 2)
  14.         {
  15.             result = a % c;
  16.         }
  17.         if (b == 4)
  18.         {
  19.             result = a + c;
  20.         }
  21.         if (b == 8)
  22.         {
  23.             result = a * c;
  24.         }
  25.  
  26.         decimal remainder = result % 4;
  27.  
  28.         if (remainder == 0)
  29.         {
  30.             Console.WriteLine(result / 4);
  31.         }
  32.         else
  33.         {
  34.             Console.WriteLine(remainder);
  35.         }
  36.  
  37.         Console.WriteLine(result);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement