Question

In: Computer Science

Write a program that computes the product of two fractions. The user provides 4 input which...

Write a program that computes the product of two fractions. The user provides 4 input which represent the numerator and the denominator of two fractions and prints the result of the operation. The program uses two functions. One called MultiplyNumerator(…) which calculates the product of the numerators of the fractions, and a second one called MultiplyDenom(…) which calculates the product of the denominator of the fractions. Call your program MultiplyFrac.cpp

Solutions

Expert Solution

hello,

let me provide you the code for your problem:-

code starts here:-

#include <iostream>

using namespace std;
int MultiplyNumerator(int a,int b)
{
    return a*b;
}
int MultiplyDenom(int a,int b)
{
    return a*b;
}

int main()
{
    int numerator1,numerator2,denominator1,denominator2;
    int numerator_result,Denominator_result;
    cout<<"Enter Numerator of First Function: ";
    cin>>numerator1;
    cout<<"Enter Denominator of First Function: ";
    cin>>denominator1;
    cout<<"Enter Numerator of Second Function: ";
    cin>>numerator2;
    cout<<"Enter Denominator of Second Function: ";
    cin>>denominator2;
    numerator_result=MultiplyNumerator(numerator1,numerator2);
    Denominator_result=MultiplyDenom(denominator1,denominator2);
    cout<<"The Product of two function will be "<<numerator_result<<"/"<<Denominator_result<<" OR "<<(double)numerator_result/Denominator_result;
  
}


code ends here:-

providing you the snapshot of the code to reduce the confusion in indentation of the code:-

providing you the sample output of the code:-

i hope i was able to solve your problem to a greater extent, please feel free to comment your queries, i will surely respond to them.

Please consider my efforts and upvote my solution.

Thanku:)


Related Solutions

Write a program that prompts the user to enter a positive integer and then computes the...
Write a program that prompts the user to enter a positive integer and then computes the equivalent binary number and outputs it. The program should consist of 3 files. dec2bin.c that has function dec2bin() implementation to return char array corresponding to binary number. dec2bin.h header file that has function prototype for dec2bin() function dec2binconv.c file with main function that calls dec2bin and print results. This is what i have so far. Im doing this in unix. All the files compiled...
Lab 1 Write a program in the C/C++ programming language to input and add two fractions...
Lab 1 Write a program in the C/C++ programming language to input and add two fractions each represented as a numerator and denominator. Do not use classes or structures. Print your result (which is also represented as a numerator/denominator) to standard out. If you get done early, try to simplify your result with the least common denominator. The following equation can be used to add fractions: a/b + c/d = (a*d + b*c)/(b*d) Example: 1/2 + 1/4 = ( 1(4)...
Write Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
Exercise 4 – Lists and input Using a function Write a program that prompts the user...
Exercise 4 – Lists and input Using a function Write a program that prompts the user to input a sequence of words. The program then displays a list of unique words (words that only occurred once, i.e. no repeated).
Write a C++ Program Write a program that prompts the user to input a string. The...
Write a C++ Program Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning...
You have to write a program that computes the area of a triangle. Input consists of...
You have to write a program that computes the area of a triangle. Input consists of the three points that represent the vertices of the triangle. Points are represented as Cartesian units i.e. X,Y coordinates as in (3,5). Output must be the three points, the three distances between vertices, and the area of the triangle formed by these points. The program must read the coordinates of each point, compute the distances between each pair of them and print these values....
Write a program that prompts the user to input a string. The program then uses the...
Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning of your program and...
Fraction calculator: Write a program that lets the user perform arithmetic operations on fractions.
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.The input must be validated for correct operation (+, -, *, or /) and b != 0. If any of these cases are...
ASAP (Convert decimals to fractions) Write a program that prompts the user to enter a decimal...
ASAP (Convert decimals to fractions) Write a program that prompts the user to enter a decimal number and displays the number in a fraction. Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class in Listing 13.13 to obtain a rational number for the decimal number. Use the template at https://liveexample.pearsoncmg.com/test/Exercise13_19Test.txt for your code. Sample Run 1 Enter a decimal number: 3.25 The fraction number is 13/4...
JAVA Programming (Convert decimals to fractions) Write a program that prompts the user to enter a...
JAVA Programming (Convert decimals to fractions) Write a program that prompts the user to enter a decimal number and displays the number in a fraction. Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class in LiveExample 13.13 to obtain a rational number for the decimal number. Use the template at https://liveexample.pearsoncmg.com/test/Exercise13_19.txt for your code. Sample Run 1 Enter a decimal number: 3.25 The fraction number is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT