Saturday, January 9, 2016

Complex number, reciprocal calculator

using System.IO;
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Input the real part:");
        int x = int.Parse(Console.ReadLine());

        Console.WriteLine("Input the imaginary part:");
        int y = int.Parse(Console.ReadLine());

        double dx = (double)x;
        double dy = (double)y;
        double norm = dx * dx + dy * dy;
        Console.WriteLine("The reciprocal of " + x + "+" + y + "i is " + (dx/norm) + "+" + (-dy/norm) + "i");
    }
}