I need to write a program for my class in which I need to i need to create a structure that contains three public data fields for numerator, denominator, and whole number portion. Then I need to write a main() function in which i create three Fraction objects and prompt the user to each of the fields. Then it asks me to do 5 things. I got the first few figured out but am having a problem with a few questions. Please only use If, Else or Switch statements.
First question im having issues with asks:
Determine whether the value of the first FRACTION is greater than, equal to, or less than the value of the second Fraction. for example 1/2 and 3/6 are equal. As another example, 1 1/2 and 0 3/2 are equal. Display an appropriate message indicating the results.
#include<iostream>
usingnamespace std;
struct Fraction
{
float numerator;
float denominator;
float whole;
};
int main()
{
Fraction first, second;
cout << "You will be asked to enter a whole number, a numerator and denominator for two different fractions." << endl;
cout<< "Please enter the whole number portion of the fraction: ";
cin>>first.whole;
cout << "\nPlease enter the numerator for the first fraction: ";
cin >> first.numerator;
cout << "\nPlease enter the denominator for the first fraction: ";
cin >> first.denominator;
cout<< "Please enter the whole number portion of the 2nd fraction: ";
cin>>second.whole;
cout << "\nPlease enter the numerator for the second fraction: ";
cin >> second.numerator;
cout << "\nPlease enter the denominator for the second fraction: ";
cin >> second.denominator;
//Part 3
//Assign variables to mixed fractions
int numAfter = first.whole * first.denominator + first.numerator; //Non 0 whole number
int num2After = second.whole * second.denominator + second.numerator; //Non 0 whole number
int newValue = numAfter/first.denominator; // Non 0 whole number
int new2Value = num2After/second.denominator;// Non 0 whole number
int zeroValue = first.numerator/first.denominator;
int zero2Value = second.numerator/second.denominator;
We are only allowed to use If, else, or switch statements. I don't know where to go from there.