Question: Create a program that calculates the average of a number of fractional values entered by the user. - Start by asking the user how many
Create a program that calculates the average of a number of fractional values entered by the user. - Start by asking the user how many fractions they wish to enter. - Then prompt the user to enter that number of fractions. - Then calculate and display the average of all of those values. There are a couple of additional internal C# requirements for this program: You must create (and use) a class Fraction to represent the fraction values. The obvious approach would be to have two int attributes: numerator and denominator. You must dynamically allocate (and use) an array to hold all the fractions entered by the user.
Hints - There are a number of methods you could write which would make this program simpler: DisplayFraction, EnterFraction, AddFractions, DivideFractions, etc. - If you can't remember the details of adding fractions: a/b + c/d = (ad + cb) / bd; - For division: a/b divided by c/d = ad / bc. - Don't worry about reducing your fractions. This includes extracting out the whole part of the fraction. For example, 6/4 is an acceptable answer, but your 4th grade math teacher would have asked for 1 and 1/2. - Remember that 0 is an illegal denominator value. Guard against this. - When calculating the average value and wondering how to divide a fraction value by an int value, remember that an integer, for example 3, is equivalent to 3/1 as a fraction. - You can't get away with just dividing the numerator by the number of values entered because the result may not be an integer value.
=======
C# console based program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
