Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fractions Give the follwing answers. 1) Pseudocode of the whole Program. 2) The Program in C++ which exactly matches with the Pseudocode. Task: Add several

Fractions

Give the follwing answers.

1) Pseudocode of the whole Program.

2) The Program in C++ which exactly matches with the Pseudocode.

Task: Add several pairs of fractions and simplify the resulting sums. The program should be able to manage signed numbers, like or unlike denominators, and input values of zero in either a numerator or a denominator. A zero denominator should be handled by printing an appropriate error message in the output file and without causing a program abend. The final sums should be reduced to lowest terms, and improper fractions should be converted to mixed numbers. Use the Euclidean algorithm to find the GCF to simplify fractions.

Input: For each pair of fractions, accept input values for numerator 1, denominator 1, numerator 2, and denominator 2. The input data file is: P5Fractions.txt. All the input values are integers. Here are the fractions that will be added:

5/17 + 2/17,

-25/41 + 1/2,

0/2 + -3/-4

3/8 + 1/6,

1/6 + -5/6 ,

-9/11 + -10/11

9/2 + 7/2,

1/4 + -1/4,

3/7 + 4/0

8/9 + 11/3,

-1/3 + -7/8,

-3/-5 + -15/-7

Output: Print an appropriate header in the output file, and then print each pair of addend fractions and their sum. Note that negative signs should not be displayed in a denominator. If a mixed number is negative, print only one minus sign (i.e., print 1 1/4 rather than 1 1/4 ). If the final result is an integer, no fraction portion should be displayed. If the final result is only a fraction with no whole number part, do not print a whole number of 0.

Sample output: 3/8 + 1/6 = 13/24 9/2 + 7/2 = 8 8/9 + 11/3 = 4 5/9 1/6 + 5/6 = 2/3 9/11 + 10/11 = 1 8/11

Suggestions: You might want to simplify the answer after combining the fractions.

The following formula provides one way to add fractions: n1/d1 + n2/d2 = n1d2 + n2d1/d1d2

Be particularly careful calculating the signs of the answers since the Euclidian algorithm may return a negative GCF.

The input data file is:

P5Fractions.txt.

5 17 2 17 3 8 1 6 9 2 7 2 8 9 11 3

-25 41 1 2

1 6 -5 6 1 4 -1 4 -1 3 -7 8 0 2 -3 -4 -9 11 -10 11 3 7 4 0 -3 -5 -15 -7

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Who will receive the final evaluation?

Answered: 1 week ago