Create a fraction calculator program, Programming Languages

Assignment Help:

You need to create a Fraction calculator program.You need to create a Fraction class to represent fraction objects and a FractionCalculator class that will perform operations on fractions. Make sure you use input validation, so your program doesn't crash.

Requirements for Class Components:

• You need to create a Fraction class that stores information regarding fractions.

o The class should have private instance fields for this class called numerator and denominator.

o You need properties to get/set these values.
 Name them Numerator and Denominator.
o The class needs a constructor that accepts two strings that are used to construct a fraction object: one for the numerator, and one for the denominator.

o The class needs a constructor that accepts two integers that are used to construct a fraction object.

o You need an Equals() method that returns true when a fraction passed into the method is equal to the fraction object the method was called upon.

 Example: If frac1.equals(frac2) Then ...

o You need a ToString() method that returns a string representation of a fraction.

For example, a fraction with a numerator of 5 and a denominator of 6 would return "5/6" when the ToString method is called.

• You need to create a FractionCalculator class will be responsible for working with two fractions.

o This class should be used to perform addition, subtraction, multiplication, and divide.

o The Add, Subtract, Multiply, and Divide methods should take two fractions objects as input and return a new fraction which is the result of the operation that was performed on the two input fractions.

o This class needs a Swap() method that will accept two fraction objects and swap them.

o This class needs an Invert() method that will accept a single fraction object and swap the numerator and denominator.
 For example, fraction "3/4" becomes "4/3"

o Try creating a Reduce() method to simply fractions for an extra credit challenge.

 Hint: you will need recursion and the Euclidean Algorithm.

User InterfaceRequirements:

• You need to create a form that allows the user to enter two fractions, perform a specific operation (+, -, *, /, swap, and invert), and display the results.

• Display clear instructions to the user where necessary.

Fraction Help:

Adding fractions: a/b + c/d
(ad + bc) / bd

Subtracting fractions: a/b - c/d
(ad - bc) / bd

Multiplying fractions: a/b * c/d
(a * c) / (b * d)

Dividing fractions: (a/b) / (c/d)
(a * d) / (b * c)


Related Discussions:- Create a fraction calculator program

Write a booking and pricing system, Write a booking and pricing system for ...

Write a booking and pricing system for seats for performances in a theatre. Design and write a system to handle information (equipment, people, events etc.) for a club. Given

Built a liner program to manage a staff, A manager at the local Walmart nee...

A manager at the local Walmart needs to determine how many workers to hire to cover a 24-hour period. Each worker must work 9 consecutive hours but may only start work at the begin

Api in c#, i what to know how setcapture() api work in c#

i what to know how setcapture() api work in c#

Read Multiple Text Files, How to read datasets in multiple text files in an...

How to read datasets in multiple text files in an non interactive program?

Introduction to javascript, This is the programming language of the Web. It...

This is the programming language of the Web. It is mainly used for validating forms. JavaScript & Java can be associated to each other. There exist several other differences betwee

Information system, analyse the information need in the different functiona...

analyse the information need in the different functional area in any organization

Add external style sheet in html code, On a single XHTML page, include the ...

On a single XHTML page, include the following two div container elements in the body. Using an external stylesheet, add style to the div elements such that one div has some overlap

DOM - Document Object Model, What is DOM? The Document Object Model is a pl...

What is DOM? The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure an

Super ascii string cost in c++, Ask question #Minimum 100 A string S is sai...

Ask question #Minimum 100 A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets

Implement a two-dimensional table in prolog, Implement a two-dimensional ta...

Implement a two-dimensional table in Prolog. Your program will contain: 1.  An insert_entry predicate that takes a table, row, column and an entry and inserts the entry at the g

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd