Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Exercise#2: Fraction Calculator Open the file Problem 2.cpp Write a Ctt program that simulates a calculator for performing arithmetic operations on fractions ractions are

image text in transcribedC++
Exercise#2: Fraction Calculator Open the file Problem 2.cpp Write a Ctt program that simulates a calculator for performing arithmetic operations on fractions ractions are of the form a/b where a and b are integers and b z o. The program asks the user to enter four values n1, d1, n2, d2 that represent the numerator and the denominator of the two fractions followed then the two fractions are minato by one of the four operations (t,, , or /). For example if the array has 3 4 5 6 3/4 and 5/6. If a denominator is 0 then the program terminates and prints the message "Deno prints the message "Invalid operator. Program terminates" The program has the following functions can't be zero. Program terminates". If the operation is not one of the characters +,, or/the prograr float addFractions(int, int, int, int): The function adds the two fractions and returns the result as a flo number. For example the program returns 1.58333 if the function arguments are 3 4 56. float subFractions(int, int, int, int): The function subtracts the two fractions and returns the result a float number. For example the program returns-0.08333 if the function arguments are 3 4 5 6 void mulFractions(int, int, int, int, int &, int &): The function multiples the two fractions. The mais function prints the result of the multiplication of the two fractions as a fraction number. For example main() prints 15/24 if the function arguments are 3 456 void divFractions(int, int, int, int, int &, int &): The function divides the two fractions. The main() funct prints the result of the multiplication of the two fractions as a fraction number. For example the moai prints 18/20 if the function arguments are 3 456 Sample input/output: nter the numerator and the denominator of the first number:34 nter the numerator and the denominator of the second number: 5 6 er one of the four operator +,or /: + he results of adding the two fractions are: 1.58333

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

=+ c. a company president deciding whether to open a new factory

Answered: 1 week ago