Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/ComplexCalculator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,41 @@ class Program
{
static void Main(string[] args)
{
Console.WriteLine("This program adds 2 complex numbers");
ComplexNumber c1 = new ComplexNumber
{
Real = ReadDouble("Enter Real Part of first complex number"),
Imaginary = ReadDouble("Enter Imaginary part of first complex number")
};
ComplexNumber c2 = new ComplexNumber
{
Real = ReadDouble("Enter Real Part of second complex number"),
Imaginary = ReadDouble("Enter Imaginary part of second complex number")
};

var c3 = c1.Add(c2);

Console.WriteLine("{0} + {1} = {2} with modulous {3}", c1, c2, c3, c3.Modulous());
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Modulus not Modulous

}

private static double ReadDouble(string message)
{
double val;
string s;
bool success = false;
do
{
Console.Write(message + ":");
s = Console.ReadLine();
success = double.TryParse(s, out val);
if (!success)
{
Console.WriteLine("ERROR please try again.");
}
} while (!success);

return val;

}
}
}