in C# i need to Add an operator*() method to the Fraction class created in Programming Exercise 11a so that it correctly multiplies two Fractions. The result should be in proper, reduced format. Demonstrate that the method works correctly in a program named FractionDemo2. my errors are he Fraction class operator*() method defined for Fraction class 4 0 out of 4 checks passed. Review the results below for more details. Checks Unit Test Incomplete Fraction's operator*() multiplication test 1 Build Status Build Failed Build Output Compilation failed: 1 error(s), 0 warnings NtTestac341aa4.cs(18,29): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) Test Contents [TestFixture] public class FractionClassMultiplyTest { [Test] public void FractionMultiplyTest() { Fraction f1 = new Fraction(5, 3, 9); Fraction f2 = new Fraction(16, 2, 7); Fraction res; res = f1 * f2; Assert.AreEqual(86, res.WholeNum); Assert.AreEqual(6, res.Numerator); Assert.AreEqual(7, res.Denominator); } } Unit Test Incomplete Fraction's operator*() multiplication test 2 Build Status Build Failed Build OutputCompilation failed: 1 error(s), 0 warnings NtTest1a622ccc.cs(19,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) Test Contents [TestFixture] public class FractionClassMultiplyTest { [Test] public void FractionMultiplyTest2() { Fraction f1 = new Fraction(2, 0, 1); Fraction f2 = new Fraction(4, 1, 8); Fraction res; res = f2 * f1; Assert.AreEqual(8, res.WholeNum); Assert.AreEqual(1, res.Numerator); Assert.AreEqual(4, res.Denominator); } } Unit Test Incomplete Fraction's operator*() multiplication test 3 Build Status Build Failed Build Output Compilation failed: 1 error(s), 0 warnings NtTest4e97e3d6.cs(18,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) Test Contents [TestFixture] public class FractionClassMultiplyTest { [Test] public void FractionMultiplyTest2() { Fraction f1 = new Fraction(1, 0, 1); Fraction f2 = new Fraction(4, 0, 1); Fraction res; res = f2 * f1; Assert.AreEqual(4, res.WholeNum); Assert.AreEqual(0, res.Numerator); Assert.AreEqual(1, res.Denominator); } } Unit Test Incomplete Fraction's operator*() multiplication test 4 Build Status Build Failed Build Output Compilation failed: 2 error(s), 0 warnings NtTest8dd488f5.cs(18,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) NtTest8dd488f5.cs(19,30): error CS1061: Type `Fraction' does not contain a definition for `FracString' and no extension method `FracString' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) Test Contents [TestFixture] public class FractionClassMultiplyTest { [Test] public void FractionMultiplyTest2() { Fraction f1 = new Fraction(0, 1, 1); Fraction f2 = new Fraction(0, 1, 1); Fraction res; res = f2 * f1; Assert.AreEqual(1, res.WholeNum); Assert.AreEqual("1", res.FracString()); } } my code is in the pictures
in C# i need to Add an operator*() method to the Fraction class created in Programming Exercise 11a so that it correctly multiplies two Fractions. The result should be in proper, reduced format. Demonstrate that the method works correctly in a program named FractionDemo2. my errors are he Fraction class operator*() method defined for Fraction class 4 0 out of 4 checks passed. Review the results below for more details. Checks Unit Test Incomplete Fraction's operator*() multiplication test 1 Build Status Build Failed Build Output Compilation failed: 1 error(s), 0 warnings NtTestac341aa4.cs(18,29): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) Test Contents [TestFixture] public class FractionClassMultiplyTest { [Test] public void FractionMultiplyTest() { Fraction f1 = new Fraction(5, 3, 9); Fraction f2 = new Fraction(16, 2, 7); Fraction res; res = f1 * f2; Assert.AreEqual(86, res.WholeNum); Assert.AreEqual(6, res.Numerator); Assert.AreEqual(7, res.Denominator); } } Unit Test Incomplete Fraction's operator*() multiplication test 2 Build Status Build Failed Build OutputCompilation failed: 1 error(s), 0 warnings NtTest1a622ccc.cs(19,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) Test Contents [TestFixture] public class FractionClassMultiplyTest { [Test] public void FractionMultiplyTest2() { Fraction f1 = new Fraction(2, 0, 1); Fraction f2 = new Fraction(4, 1, 8); Fraction res; res = f2 * f1; Assert.AreEqual(8, res.WholeNum); Assert.AreEqual(1, res.Numerator); Assert.AreEqual(4, res.Denominator); } } Unit Test Incomplete Fraction's operator*() multiplication test 3 Build Status Build Failed Build Output Compilation failed: 1 error(s), 0 warnings NtTest4e97e3d6.cs(18,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) Test Contents [TestFixture] public class FractionClassMultiplyTest { [Test] public void FractionMultiplyTest2() { Fraction f1 = new Fraction(1, 0, 1); Fraction f2 = new Fraction(4, 0, 1); Fraction res; res = f2 * f1; Assert.AreEqual(4, res.WholeNum); Assert.AreEqual(0, res.Numerator); Assert.AreEqual(1, res.Denominator); } } Unit Test Incomplete Fraction's operator*() multiplication test 4 Build Status Build Failed Build Output Compilation failed: 2 error(s), 0 warnings NtTest8dd488f5.cs(18,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) NtTest8dd488f5.cs(19,30): error CS1061: Type `Fraction' does not contain a definition for `FracString' and no extension method `FracString' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error) Test Contents [TestFixture] public class FractionClassMultiplyTest { [Test] public void FractionMultiplyTest2() { Fraction f1 = new Fraction(0, 1, 1); Fraction f2 = new Fraction(0, 1, 1); Fraction res; res = f2 * f1; Assert.AreEqual(1, res.WholeNum); Assert.AreEqual("1", res.FracString()); } } my code is in the pictures
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
in C# i need to
Add an operator*() method to the Fraction class created in Programming Exercise 11a so that it correctly multiplies two Fractions. The result should be in proper, reduced format. Demonstrate that the method works correctly in a program named FractionDemo2.
my errors are
he Fraction class operator*() method defined for Fraction class
4
0 out of 4 checks passed. Review the results below for more details.
Checks
Unit Test
Incomplete
Fraction's operator*() multiplication test 1
Build Status
Build Failed
Build Output
Compilation failed: 1 error(s), 0 warnings
NtTestac341aa4.cs(18,29): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error)
[TestFixture]
public class FractionClassMultiplyTest
{
[Test]
public void FractionMultiplyTest()
{
Fraction f1 = new Fraction(5, 3, 9);
Fraction f2 = new Fraction(16, 2, 7);
Fraction res; res = f1 * f2;
Assert.AreEqual(86, res.WholeNum);
Assert.AreEqual(6, res.Numerator);
Assert.AreEqual(7, res.Denominator);
}
}
Unit Test
Incomplete
Fraction's operator*() multiplication test 2
Build Status
Build Failed
Build OutputCompilation failed: 1 error(s), 0 warnings NtTest1a622ccc.cs(19,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error)
[TestFixture]
public class FractionClassMultiplyTest
{
[Test]
public void FractionMultiplyTest2()
{
Fraction f1 = new Fraction(2, 0, 1);
Fraction f2 = new Fraction(4, 1, 8);
Fraction res; res = f2 * f1;
Assert.AreEqual(8, res.WholeNum);
Assert.AreEqual(1, res.Numerator);
Assert.AreEqual(4, res.Denominator);
}
}
Unit Test
Incomplete
Fraction's operator*() multiplication test 3
Build Status
Build Failed
Build Output
Compilation failed: 1 error(s), 0 warnings
NtTest4e97e3d6.cs(18,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error)
[TestFixture]
public class FractionClassMultiplyTest
{
[Test]
public void FractionMultiplyTest2()
{
Fraction f1 = new Fraction(1, 0, 1);
Fraction f2 = new Fraction(4, 0, 1);
Fraction res; res = f2 * f1;
Assert.AreEqual(4, res.WholeNum);
Assert.AreEqual(0, res.Numerator);
Assert.AreEqual(1, res.Denominator);
}
}
Unit Test
Incomplete
Fraction's operator*() multiplication test 4
Build Status
Build Failed
Build Output
Compilation failed: 2 error(s), 0 warnings
NtTest8dd488f5.cs(18,28): error CS1061: Type `Fraction' does not contain a definition for `WholeNum' and no extension method `WholeNum' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error)
NtTest8dd488f5.cs(19,30): error CS1061: Type `Fraction' does not contain a definition for `FracString' and no extension method `FracString' of type `Fraction' could be found. Are you missing an assembly reference? FractionDemo2.cs(3,14): (Location of the symbol related to previous error)
[TestFixture]
public class FractionClassMultiplyTest
{
[Test]
public void FractionMultiplyTest2()
{
Fraction f1 = new Fraction(0, 1, 1);
Fraction f2 = new Fraction(0, 1, 1);
Fraction res; res = f2 * f1;
Assert.AreEqual(1, res.WholeNum);
Assert.AreEqual("1", res.FracString());
}
}
my code is in the pictures
![089858 SPEER**** ***** ******** *********⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ =====
113
119
122
123
124
127
128
134
135
// Override the ToString() method to display the fraction
references
public override string ToString()
{
}
// Convert the fraction to a mixed fraction
references
public MixedFraction ToMixedFraction()
{
}
4 references
public class MixedFraction
{
return numerator + "/" + denominator;
private int wholeNum;
private int numerator;
private int denominator;
}
1 reference
public MixedFraction(int wholeNum, int numerator, int denominator)
{
int wholeNum = numerator / denominator;
int num = numerator denominator;
return new MixedFraction(wholeNum, nun, denominator);
}
references
}
this.wholeNum = wholeNum;
this.numerator = numerator;
this.denominator = denominator;
Reduce();
public
{
MixedFraction(Fraction fraction)
wholeNum = fraction. Numerator / fraction.Denominator;
numerator = fraction. Numerator & fraction.Denominator;
denominator = fraction. Denominator;
Reduce();
Ⓒreferences
public override string ToString()
{
}
if (wholeNum == 0)
{
return numerator + "/" + denominator;
}
else if (numerator == 8)
{
return wholeNum.ToString();
}
else
{
}
return wholeNum+""+ numerator / denominator;
// Reduce the mixed fraction to its lowest terms
private void Reduce()
2 references
{
int gcd = GCD(numerator, denominator);
numerator /= ged;
denominator /= gcd;
wholeNum += numerator / denominator;
numerator denominator;
}
// Calculate the greatest common divisor
2 references
private int GCD(int a, int b)
{
if (b == 0)
return a;
return GCD(b, a & b);](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fda2a136f-d248-470a-adf7-afa3bf81602c%2F8d124d05-1963-4d1c-affe-5a7ebb263110%2Fnban5i8_processed.png&w=3840&q=75)
Transcribed Image Text:089858 SPEER**** ***** ******** *********⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ =====
113
119
122
123
124
127
128
134
135
// Override the ToString() method to display the fraction
references
public override string ToString()
{
}
// Convert the fraction to a mixed fraction
references
public MixedFraction ToMixedFraction()
{
}
4 references
public class MixedFraction
{
return numerator + "/" + denominator;
private int wholeNum;
private int numerator;
private int denominator;
}
1 reference
public MixedFraction(int wholeNum, int numerator, int denominator)
{
int wholeNum = numerator / denominator;
int num = numerator denominator;
return new MixedFraction(wholeNum, nun, denominator);
}
references
}
this.wholeNum = wholeNum;
this.numerator = numerator;
this.denominator = denominator;
Reduce();
public
{
MixedFraction(Fraction fraction)
wholeNum = fraction. Numerator / fraction.Denominator;
numerator = fraction. Numerator & fraction.Denominator;
denominator = fraction. Denominator;
Reduce();
Ⓒreferences
public override string ToString()
{
}
if (wholeNum == 0)
{
return numerator + "/" + denominator;
}
else if (numerator == 8)
{
return wholeNum.ToString();
}
else
{
}
return wholeNum+""+ numerator / denominator;
// Reduce the mixed fraction to its lowest terms
private void Reduce()
2 references
{
int gcd = GCD(numerator, denominator);
numerator /= ged;
denominator /= gcd;
wholeNum += numerator / denominator;
numerator denominator;
}
// Calculate the greatest common divisor
2 references
private int GCD(int a, int b)
{
if (b == 0)
return a;
return GCD(b, a & b);
![2
3
4
5
6
24
15
16
17
18
19
20
21
22
25
26
27
28
29
30
$1
52
33
34
$5
36
3
5
6
17
8
19
51
52
63
54
55
56
57
58
59
50
using System;
8 references
public class Fraction
{
private int numerator;
private int denominator;
2 references
public int Numerator
{
}
3 references
public int Denominator
{
}
}
1 reference
public Fraction(int nun, int denom)
{
}
get { return numerator; }
set { numerator = value; }
O references
public Fraction(int whole, int num, int denom)
{
}
get { return denominator; }
set { denominator = value; }
}
numerator = num;
denominator = denom;
// Define the operator for Fraction objects
O references
public static Fraction operator *(Fraction a, Fraction b
{
}
numerator whole denom + num;
denominator denon;
Reduce();
// Reduce the fraction to its lowest terms
2 references
public Fraction Reduce()
{
int gcd = GCD(numerator, denominator);
numerator /= gcd;
denominator /= ged;
int num= a.numerator b.numerator;
int denon = a.denominator * b. denominator;
return new Fraction (num, denon). Reduce();
return this;
// Calculate the greatest common divisor
2 references
private int GCD(int a, int b)
{
if (b == 0)
return a;
return GCD(b, a % b);](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fda2a136f-d248-470a-adf7-afa3bf81602c%2F8d124d05-1963-4d1c-affe-5a7ebb263110%2Fb91hkmi_processed.png&w=3840&q=75)
Transcribed Image Text:2
3
4
5
6
24
15
16
17
18
19
20
21
22
25
26
27
28
29
30
$1
52
33
34
$5
36
3
5
6
17
8
19
51
52
63
54
55
56
57
58
59
50
using System;
8 references
public class Fraction
{
private int numerator;
private int denominator;
2 references
public int Numerator
{
}
3 references
public int Denominator
{
}
}
1 reference
public Fraction(int nun, int denom)
{
}
get { return numerator; }
set { numerator = value; }
O references
public Fraction(int whole, int num, int denom)
{
}
get { return denominator; }
set { denominator = value; }
}
numerator = num;
denominator = denom;
// Define the operator for Fraction objects
O references
public static Fraction operator *(Fraction a, Fraction b
{
}
numerator whole denom + num;
denominator denon;
Reduce();
// Reduce the fraction to its lowest terms
2 references
public Fraction Reduce()
{
int gcd = GCD(numerator, denominator);
numerator /= gcd;
denominator /= ged;
int num= a.numerator b.numerator;
int denon = a.denominator * b. denominator;
return new Fraction (num, denon). Reduce();
return this;
// Calculate the greatest common divisor
2 references
private int GCD(int a, int b)
{
if (b == 0)
return a;
return GCD(b, a % b);
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education