Advertisement
OneTallor

Untitled

Sep 17th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double a = 0;
  14.             double b = 0;
  15.             Console.Write("Kérem a(z) 'A' számot: ");
  16.             a = Convert.ToDouble(Console.ReadLine());
  17.             Console.Write("Kérem a(z) 'B' számot: ");
  18.             b = Convert.ToDouble(Console.ReadLine());
  19.  
  20.             double c = a / b;
  21.             double d = b / a;
  22.  
  23.             if (a < b)
  24.             {
  25.                 if (a == 0)
  26.                 {
  27.                     Console.ForegroundColor = ConsoleColor.Red;
  28.                     Console.WriteLine("Nullával nem lehet osztani");
  29.                     Console.ResetColor();
  30.                 }
  31.                 else
  32.                     Console.WriteLine("'B' osztva 'A'-val: {0:0.00} ", d);
  33.                
  34.             }
  35.             if (b < a)
  36.             {
  37.                 if (b == 0)
  38.                 {
  39.                     Console.ForegroundColor = ConsoleColor.Red;
  40.                     Console.WriteLine("Nullával nem lehet osztani");
  41.                     Console.ResetColor();
  42.                 }
  43.                 else
  44.                     Console.WriteLine("'A' osztva 'B'-vel: {0:0.00} ", c);
  45.                
  46.             }
  47.             if (a == 0 && b == 0)
  48.             {
  49.                 Console.ForegroundColor = ConsoleColor.Red;
  50.                 Console.WriteLine("Hiba");
  51.                 Console.ResetColor();
  52.             }
  53.  
  54.             Console.ReadLine();
  55.  
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement