DO THIS IN C-Sharp (C#)   Create a file called Fraction.cs that contains a class called Fraction. The Fraction class should have 2 private fields: double numerator and double denominator and each should have public properties with default getters and setters. The Fraction class should have five (5) constructors: A constructor that allows the user to initialize both the numerator and denominator fields. A constructor that allows the user to initizlize the numerator and sets the denominator to 1,  A constructor that takes in a string of the form "num / den" that sets the numerator and denominator based off of the stirng. For this, use the string.Split(" / ") method to get the numerator and denominator into a string array, then use Int32.Parse() to turn them into actual integers. A default constructor that defaults the numerator to 0 and the denominator to 1. The class should contain six (6) methods: Add(Fraction o) that adds two fractions together and returns a new Fraction [Don't worry about reducing to lowest form].  Sub(Fraction o) that subtracts two fractions and returns a new Fraction[a.Sub(b) should be equivalent to a - b] Mult(Fraction o) that multiplies two fractions together and returns a new Fraction. Div(Fraction o) that divides two fractions together and returns a new Fraction. ToDecimal() that returns the value of dividing the numerator and denominator. ToString() that displays the fraction as "num / den" No need to implement the operator static methods

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question

DO THIS IN C-Sharp (C#)

 

Create a file called Fraction.cs that contains a class called Fraction.
The Fraction class should have 2 private fields: double numerator and double denominator and each should have public properties with default getters and setters.
The Fraction class should have five (5) constructors:
A constructor that allows the user to initialize both the numerator and denominator fields.
A constructor that allows the user to initizlize the numerator and sets the denominator to 1, 
A constructor that takes in a string of the form "num / den" that sets the numerator and denominator based off of the stirng.
For this, use the string.Split(" / ") method to get the numerator and denominator into a string array, then use Int32.Parse() to turn them into actual integers.
A default constructor that defaults the numerator to 0 and the denominator to 1.

The class should contain six (6) methods:

Add(Fraction o) that adds two fractions together and returns a new Fraction [Don't worry about reducing to lowest form]. 
Sub(Fraction o) that subtracts two fractions and returns a new Fraction[a.Sub(b) should be equivalent to a - b]
Mult(Fraction o) that multiplies two fractions together and returns a new Fraction.
Div(Fraction o) that divides two fractions together and returns a new Fraction.
ToDecimal() that returns the value of dividing the numerator and denominator.
ToString() that displays the fraction as "num / den"

No need to implement the operator static methods.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 8 images

Blurred answer
Knowledge Booster
void method
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage