Create a fraction calculator program, Programming Languages

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)

Posted Date: 2/15/2013 12:56:22 AM | Location : United States







Related Discussions:- Create a fraction calculator program, Assignment Help, Ask Question on Create a fraction calculator program, Get Answer, Expert's Help, Create a fraction calculator program Discussions

Write discussion on Create a fraction calculator program
Your posts are moderated
Related Questions
Define the Control statements in Computer Programming? The statements are part of the program that performs some action. The compiler will check a program sequentially from the

these 8 numbers (15, 20, 25, 30, 35, 40, 45, and 50) with using conditional jump

Python Programming hmw help!! Write a program that ask the user to input the followings: number of shares, stock price, and broker commission. Last month jim purchased some stock

I need help putting this into a flowchart constant c as Integer = 3500 Constant CALORIESTOOUNCE as Integer = 219 Declare Sex as Character Declare Age as Integer Declare Weight as I

Write your own version of the strcmp function string_compare. Supply a main program that will test each of the 3 differing outcomes. int string_compare(char *s, cha

(a) Define a procedure called make-avl-tree which makes an AVL tree with one node. Also create another constructor build-avl-tree that creates an AVL tree from a root, left subtree

The program presents mainframe contains two button new user, existing user PART ONE: CLICKING ON NEW USER New window appear contains: text field represent username,

The objectives of this assignment are to test your ability to create XML documents to contain well-defined information. This assignment will be used further in Assignment 2, so ple

Problem Specification I/O programming is the \bread and butter", the raison d'etre, of microcontrollers. After all, our definition of a microcontroller is \a microprocessor wit

Your task for this project is to develop a system that would provide the following features: 1. Register new student 2. Drop student from university 3. Add a course and gr