Advertisement
Layvu

Cons3, Целостность данных

Nov 30th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Fractions
  4. {
  5.     public class Fraction
  6.     {
  7.         private double _numerator;
  8.         private double _denominator;
  9.  
  10.         public Fraction( int numerator, int denominator)
  11.         {
  12.             _numerator = numerator;
  13.             if (denominator == 0) throw new ArgumentException();
  14.             _denominator = denominator;
  15.         }
  16.  
  17.         public double Value { get { return _numerator / _denominator;  } }
  18.     }
  19.  
  20.     internal class Program
  21.     {
  22.         static void Main()
  23.         {
  24.             var inputLine = Console.ReadLine();
  25.             var numbFirst = int.Parse(inputLine.Split()[0]);
  26.             var numbSecond = int.Parse(inputLine.Split()[1]);
  27.  
  28.             var test = new Fraction(numbFirst, numbSecond);
  29.             Console.WriteLine(test.Value);
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement