I am working on an assignment that requires me to display a users full name and multiply two fractions however I do not understand how I get fractions to display. If someone could please help me with this I would greatly appreciate it. Here is what I have done so far:
#include <iostream>
using namespace std;
int main ()
{
string firstname, lastname ;
float fraction1 (1.0/4.0), fraction2 (1.0/2.0), product ;
Here is my problem statement, if this helps, as well:
Write a program that reads a users first and last name. The program should also read and store the numerators and denominators of two fractions as float values. For example, if the numbers 1 and 4 are entered for a fraction, the fraction is 1/4. The program should combine the users first and last names into one string variable and display the whole name. The program should calculate the product of the two fractions and display the result as a fraction and as a decimal value.
Display example:
FirstName LastName
1/4 * 1/2 = 1/8 and 0.125
You'll have to read and store the numerators and denominators separately.
If you're not required to simplify the fraction (the problem statement doesn't say anything about that), this should actually be fairly easy -- to multiply, you simply multiply the numerators and multiply the denominators, then just display those two values separated by a '/'.
For the decimal value, you just do the same, except you actually divide instead of printing a '/' character.