Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please code using c++ you are to extend the fraction multiplication examples given in class to perform fraction addition (using struct only, not classes). Each

please code using c++

you are to extend the fraction multiplication examples given in class to perform fraction addition (using struct only, not classes). Each fraction only consists of a numerator and a denominator. The program will query the user for 2 fractions and then perform the addition. It should ask the user to provide another set of fractions to perform until the denominator of either fraction entered is 0.

For example if the user enters 2 3 1 3, it means that the 2 fractions are 2/3 and 1/3. The sum of these two fractions would be 1 / 1. Please make sure the sum is written in the reduced form (but not mixed fraction). In the above example, 3 / 3 is not reduced. Furthermore, if the result is 9/6, the reduced form is 3/2. You do not need to convert it to a mixed fraction.

In your program, you must use struct fraction data type, as in the lectures. When computing the sum, use a sum() function:

fraction sum(fraction f1, fraction f2)

Example execution:

Please enter 2 fractions (numerator denominator): 2 3 1 3

The sum is 1 / 1

Please enter 2 fractions (numerator denominator): 2 3 3 4

The sum is 17 / 12

Please enter 2 fractions (numerator denominator): 2 9 5 6

The answer is 19 / 18

Please enter 2 fractions (numerator denominator): 3 8 1 6

The answer is 13 / 24

Please enter 2 fractions (numerator denominator): 2 0 1 3

Good bye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

Explain the strength of acid and alkali solutions with examples

Answered: 1 week ago

Question

Introduce and define metals and nonmetals and explain with examples

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago