Need someone that is really good at programming code in C#. Here’s the assignment;
Instructions: The do-while loop tests the while condition at the end of the loop, instead of at the beginning. This means the loop will execute at least once before testing the condition. We set the testing parameters before the do-while loop, but we need to add code inside the do-while loop so that it has a chance to test those parameters. I need you to add the correct lines of code in the correct area of the loop.
And this is the code from class that needs a do-while loop added.
namespace MethodsCalculator
{
class Calculator
{
static void Main(string[] args)
{
Operations operation = new Operations();
string input = “”;
Console.WriteLine(“This application will add, subtract, multiply, and divide by calling methods.”);
Console.WriteLine(“Choose ‘1’ for addition.”);
Console.WriteLine(“Choose ‘2’ for subtraction.”);
Console.WriteLine(“Choose ‘3’ for multiplication.”);
Console.WriteLine(“Choose ‘4’ for division.”);
Console.WriteLine(“Choose ‘x’ to quit.”);
do
{
if (input == “1”)
{
operation.add();
}
if (input == “2”)
{
operation.subtract();
}
if (input == “3”)
{
operation.multiply();
}
if (input == “4”)
{
operation.divide();
}
} while (input != “x”);
}
class Operations
{
public void add()
{
Console.Write(“Enter a number: “);
double a = Convert.ToDouble(Console.ReadLine());
Console.Write(“Enter a number: “);
double b = Convert.ToDouble(Console.ReadLine());
double sum = a + b;
Console.WriteLine(a + ” + ” + b + ” = ” + sum);
Console.WriteLine(“”);
}
public void subtract()
{
Console.Write(“Enter a number: “);
double a = Convert.ToDouble(Console.ReadLine());
Console.Write(“Enter a number: “);
double b = Convert.ToDouble(Console.ReadLine());
double diff = a – b;
Console.WriteLine(a + ” – ” + b + ” = ” + diff);
Console.WriteLine(“”);
}
public void multiply()
{
Console.Write(“Enter a number: “);
double a = Convert.ToDouble(Console.ReadLine());
Console.Write(“Enter a number: “);
double b = Convert.ToDouble(Console.ReadLine());
double product = a * b;
Console.WriteLine(a + ” x ” + b + ” = ” + product);
Console.WriteLine(“”);
}
public void divide()
{
Console.Write(“Enter a number: “);
double a = Convert.ToDouble(Console.ReadLine());
Console.Write(“Enter a number: “);
double b = Convert.ToDouble(Console.ReadLine());
double quotient = a / b;
Console.WriteLine(a + ” / ” + b + ” = ” + quotient);
Console.WriteLine(“”);
}
}
}
}
Computer Science homework help