Question: I need Assistance with my solution please fix it and explain how it was done and where i made the mistake . Thank you You

I need Assistance with my solution please fix it and explain how it was done and where i made the mistake . Thank you

You are developing a Fraction structure for Teachers Pet Software. The structure contains

three public data fields for whole number, numerator, and denominator. Using the

same structure, write a main()function that declares an array of five Fraction objects.

Prompt the user for values for each field of each Fraction. Do not allow the user to enter

a value of 0 for the denominator of any Fraction; for each Fraction, continue to prompt

the user for a denominator value until a non-zero value is entered. After all the objects

have been entered:

Display the whole number, numerator, and denominator for each of the five Fraction

objects as entered.

Next, display the five Fraction objects all converted to proper formthat is, if the user

entered a value such as 2 6/4, now display it as 3 1/2.

Next, display the sum of all the Fractions and the arithmetic average of all the

Fractions.

My solution :

#include

using namespace std;

//Using the struct fraction

struct fraction

{

int wholenumber;

int numerator;

int denominator;

};

int main()

{

// Declare an object of fraction

const int size = 5;

fraction fraction[size];

// Read five function objects

for (int index = 0; index < 5; index++);

{

cout << "Enter the whole number of fraction : ";

cin >> fraction[size].wholenumber;

cout << "Enter the numerator number of fraction : ";

cin >> fraction[size].numerator;

cout << "Enter the denominator number of fraction : ";

cin >> fraction[size].denominator;

do

{

cout << "Enter the denominator number of fraction : ";

cin >> fraction[size].denominator;

while (fraction[size].denominator == 0)

cout << "invalid entry";

cout << "Enter the denominator number of fraction:" ;

cin >> fraction[size].denominator;

}

{

//Calculations

fraction[size].numerator = fraction[size].wholenumber*fraction[size].denominator + fraction[size].numerator;

fraction[size].denominator = fraction[size].denominator;

fraction[size].wholenumber = fraction[size].numerator / fraction[size].denominator;

fraction[size].numerator = fraction[size].numerator % fraction[size].denominator;

fraction[size].denominator = fraction[size].denominator;

}

for (int index = 0; index <= fraction[size].numerator && index<= fraction[size].denominator; ++index);

{

if(fraction[size].numerator% index == 0 && fraction[size].denominator% index ==0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!