Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(C++ please help) 1. Implement a calculator in C++ that works with fractions. You will need one class: Fraction - An object of this class
(C++ please help)
1. Implement a calculator in C++ that works with fractions. You will need one class: Fraction - An object of this class represents a fraction. The class contains function for operating on the fraction. . Arithmetic with Fractions Components Two integers, known as the numerator and the denominator. How printed Restrictions The denominator may not be zero. Normalization GCD) of n and d is 1 (use Euclid's algorithm-you can look this up); and n/d, where n is the numerator and d is the denominator. However, if the denominator is 1, then only the numerator nis printed. The fraction is always kept in the lowest terms, that is, the Greatest Common Divisor The denominator is never negative. Addition a/bc/d is (ad bc)/bd Subtraction a/b -c/d is (ad - bc)/bd Multiplication! (a/b) (c/d) is (a*c)/(b*d) * Division (/b / (c/d) is (a*d)/(b*c) Absolute Assuming that a/b is normalized: Valuea ?a b :-a / b Negation-(a/b) is -a/b Special Inverse of a/b is b/a Equality lowest terms, numerators are equal and denominators are equal. Comparison a/b is less than c/d if adbc Zero Zero is represented with a numerator of zero and a denominator of one. 1. Implement a calculator in C++ that works with fractions. You will need one class: Fraction - An object of this class represents a fraction. The class contains function for operating on the fraction. . Arithmetic with Fractions Components Two integers, known as the numerator and the denominator. How printed Restrictions The denominator may not be zero. Normalization GCD) of n and d is 1 (use Euclid's algorithm-you can look this up); and n/d, where n is the numerator and d is the denominator. However, if the denominator is 1, then only the numerator nis printed. The fraction is always kept in the lowest terms, that is, the Greatest Common Divisor The denominator is never negative. Addition a/bc/d is (ad bc)/bd Subtraction a/b -c/d is (ad - bc)/bd Multiplication! (a/b) (c/d) is (a*c)/(b*d) * Division (/b / (c/d) is (a*d)/(b*c) Absolute Assuming that a/b is normalized: Valuea ?a b :-a / b Negation-(a/b) is -a/b Special Inverse of a/b is b/a Equality lowest terms, numerators are equal and denominators are equal. Comparison a/b is less than c/d if adbc Zero Zero is represented with a numerator of zero and a denominator of oneStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started