Question: In a C# console app, I was able to complete steps 1-5, but am having problems with step 6. My code so far is below

In a C# console app, I was able to complete steps 1-5, but am having problems with step 6. My code so far is below the steps.

Create a class in a file MathmaticsOperations.cs under c:\mycsharp folder.

You need to create the following methods

1) MathmaticsAddition: to add two numbers

2) MathmaticsSubtraction: to subtract two numbers

1) Make sure that you create all the necessary elements for the class, such as attributes, constructor.

2) Make sure that each method accepts and return the correct data type

3) Create a driver program TestMathmaticsOperations.cs under c:\mycsharp folder to test the class.

4) Add comments and flowerbox to all your programs

5 ) Make sure that the MathmaticsOperations.cs does not contain any UI functions such as read, print, .

The TestMathmaticsOperations should do the following

Enter the First number >> 5.5

Enter the Second Number >> 7.5

The sum of the numbers is 13

The subtract of the two numbers is -2.00

Do you want to exit (Y/N)?

// If Yes print "Thanks for using our system"

// If No run the program again

6) Modify the code to prompt you for the operation so it will look like this

Enter the First number >> 5.5

Enter the Second Number >> 7.5

Enter operator >> +

The answer is 13

Do you want another operation (Y/N)?

// If Yes print "Thanks for using our system"

// If No run the program again

MathmaticsOperations.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Mathmatics

{

class MathmaticsOperations

{

public float varAddition, varSubtraction;

public float MathmaticsAddition(float a, float b)

{

return a + b;

}

public float MathmaticsSubtraction(float a, float b)

{

return a - b;

}

public void BothOperations(float a, float b)

{

varAddition = MathmaticsAddition(a, b);

varSubtraction = MathmaticsSubtraction(a, b);

}

}

}

TestMathmaticsOperations.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Mathmatics

{

class TestMathmaticsOperations

{

static void Main(string[] args)

{

float a, b;

MathmaticsOperations add = new MathmaticsOperations();

MathmaticsOperations subtract = new MathmaticsOperations();

while (true)

{

Console.WriteLine("Enter the First number >>");

a = float.Parse(Console.ReadLine());

Console.WriteLine("Enter the Second Number >>");

b = float.Parse(Console.ReadLine());

add.BothOperations(a, b);

subtract.BothOperations(a, b);

Console.WriteLine("The sum of the numbers is " + add.varAddition.ToString());

Console.WriteLine("The subtract of the two numbers is " + subtract.varSubtraction.ToString());

Console.WriteLine("Do you want to exit (Y/N)?");

char z = Console.ReadKey().KeyChar; if (z == 'Y' || z == 'y')

ConsoleKeyInfo KeyTyped = Console.ReadKey();

Console.WriteLine("Thanks for using our system");

break;

}

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!