Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I'm trying to finish my last 3 assignments and I can't seem to figure out the code, it's bugging me if you could look

Hi I'm trying to finish my last 3 assignments and I can't seem to figure out the code, it's bugging me if you could look at my code, say what's wrong, input the write code it be greatly appreciated, I will rate highly thank you in advance this is for C++ programming language.

(Fraction calculator) | Write a program that lets the user perform arithmetic operations on fractions. Fractions are of the form a/b, in which _a_ and _b_ are integers and b 0. Your program must be menu driven, allowing the user to select the operation (+, , *, or /) and input the numerator and denominator of each fraction. Furthermore, your program must consist of at least the following functions:

Function menu: This function informs the user about the programs purpose, explains how to enter data, and allows the user to select the operation.

Function addFractions: This function takes as input four integers representing the numerators and denominators of two fractions, adds the fractions, and returns the numerator and denominator of the result. (Notice that this function has a total of six parameters.)

Function subtractFractions: This function takes as input four integers representing the numerators and denominators of two fractions, subtracts the fractions, and returns the numerator and denominator of the result. (Notice that this function has a total of six parameters.)

Function multiplyFractions: This function takes as input four integers representing the numerators and denominators of two fractions, multiplies the fractions, and returns the numerators and denominators of the result. (Notice that this function has a total of six parameters.)

Function divideFractions: This function takes as input four integers representing the numerators and denominators of two fractions, divides the fractions, and returns the numerator and denominator of the result. (Notice that this function has a total of six parameters.) Some sample outputs are:

3 / 4 + 2 / 5 = 23 / 20

2 / 3 * 3 / 5 = 6 / 15

Your answer need not be in the lowest terms.

#include "stdafx.h" #include using namespace std; void choice(int &a,int &b,int &c,int &d,char ch,int &upper,int &lower); int sum(int a,int b,int c,int d,int &upper,int &lower); int mul(int a,int b,int c,int d,int &upper,int &lower); int div(int a,int b,int c,int d,int &upper,int &lower); int sub(int a,int b,int c,int d,int &upper,int &lower); int a,b,c,d,nom,den; char operation; int main() { choice(a,b,c,d,operation,nom,den); cout<<"answer is "<>a>>b>>c>>d; cout<<"enter opperation "<>ch; switch(ch) { case '+': sum(a,b,c,d,nom,den); break; case '*': mul(a,b,c,d,nom,den); break; case '/': div(a,b,c,d,nom,den); break; case '-': sub(a,b,c,d,nom,den); break; } } int sum(int a,int b,int c,int d,int &nom,int &den) { nom=a*d+b*c; den=b*d; return nom; return den; } int mul(int a,int b,int c,int d,int &nom,int &den) { nom=a*c; den=b*d; return nom; return den; } int sub(int a,int b,int c,int d,int &nom,int &den) { nom=a*d-b*c; den=b*d; return nom; return den; } int div(int a,int b,int c,int d,int &nom,int &den) { nom=a*d; den=b*c; return nom; return den; }

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago