Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Microsoft visual studio 2017 c# FractionLab In this lab you will implement a class called fraction capable of performing basic mathmatical operations on rational
Use Microsoft visual studio 2017 c#
FractionLab
In this lab you will implement a class called fraction capable of performing basic mathmatical operations on rational numbers. a rational number can be expressed as a fraction of two whole numbers.
For a quick refresher on rational numbers, I recomend wikipedia: https://en.wikipedia.org/wiki/Rational_number
PART 0: the Main() Program?
Tests are only provided for the Fraction Class. these Unit Tests dont care how the class will be used, only the functionality the class should provide. there are empty stubs in the main program for you to put test code of your own since it may be faster to run the main program than run all the tests repeatedly. but it is not needed. However the project must still compile in order to run tests on the project.
PART 1: First Steps, constructor and properties
You should start your lab by implementing the constructors and R/W properties for the Fraction class. always be on the lookout for denominators of Zero.
That should alway raise a DivideByZeroException. PART 2: Reduce to canonical form
a private helper function stub called Reduce has been included in your class. Any rational number can be expressed as a ratio of coprime integers. Any time your fraction is modified, you should reduce your representation to its canonical form.
PART 3: Arithmetic operations
Use the provided method stubs to implement +,-,*,/ Addition and subtraction
of fractions requires a common denomenator. the quickest common denomentator is always (denominatorA* denomenatorB) this is probably not canonical form but is easy to implement. the result can be reduced before returning the result.
Multiplication
Multiplication of fractions straightforward numeratorAnumeratorB over denomenatorAdenomenatorB but must be reduced to canonical form before returning.
Division
Division is multiplication of the inverse fraction. (a/b)/(c/d) === (a/b)*(d/c) but beware of divide by zero!
PART 4: Comparison Operations
Use the provided method stubs to implement , =, ==, != Think about reducing the total amount of code you need to write by calling combinations of simple methods to create more complicated methods eg use a combination of == and
FractionLab - Microsoft Visual Studio File Edit View Project Build Incredibuild DebugTeam Tools Architecture Test FractionLab Program.cs X C Fractionab sing System; 2 E namespace FractionLab 4 Oreferences Ben Viall, 3 hours ago | 1 author, 2 changes class Program 6 Oreferences Ben Viall, 3 hours ago 1 author, 2 changes static void Main(string[] args) 7 8 9 10 // write any test code for the fraction class here. 12 O references | Ben Viall, 3 hours ago 1 author, 1 change int? getNumber() 13 14 15 16 17 return null; O references Ben Viall,3 hours ago 1 1 author, 1 change Fraction getFraction() 18 19 20 21 return new Fraction); 23 24Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started