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
icon
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)
 
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
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);
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);
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Data members
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.
Similar questions
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education