Programming in C#
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("");
}
}
}
}
11 years ago
20
- Due date: Week 4 - Sunday, March 8, by midnight CST. Points: Worth 100 pointsAssignment: Formal Analysis of a Work of...
- List of ten central values in American culture.
- $60 week 3 + $60 Advance for week 4
- power point
- Nike Contingent Claim and Timing Option
- CIS 210 Week 4 Assignment 1 Use Cases
- Week 8
- HHS 310 Week 2 DQ 1 ( Values ) ~ 2 Different Answers To Help You Score Better ~ ( Latest Syllabus - Updated Jan, 2015 - Perfect Tutorial - Scored 100% )
- WHY THE SOUTH LOST THE AMERICAN CIVIL WAR
- one