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

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

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
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