Reference no: EM13708
Problem: Build a class for a type called Fraction.
This class is used to show a ration of two integers. Include mutator functions that allow the user to set the numerator and the denominator. Also, add a member function that returns the value of the numerator divided by the denominator as a double. Include another member function that outputs the value of the fraction reduced to the lowest terms.
For illustration, instead of outputting 20/60 the function should output 1/3. This requires finding the greatest common divisor for the numerator and denominator, and then dividing both by that number. Embed your class in a test program.
For example, Write a test program that asks the user for an integer numerator and integer denominator, print the real number from evaluating the fraction, and then print the fraction reduced to its lowest terms.
Enter a numerator: 20
Enter a denominator: 60
The result of your fraction is .333333.
Your fraction in lowest terms is 1 / 3.
Prepare a Temperature class that internally stores a temperature in degrees Kelvin.
Create functions named setTempKelvin, setTempFahrenheit, and setTempCelsius that take an input temperature in the specified temperature scale, convert the temperature to Kelvin, and store that temperature in the class member variable. Also, create functions that return the stored temperature in degrees Kelvin, Fahrenheit, or Celsius.
Write a main function to test your class. Use the equations shown next to convert between the three temperatures scales.
Kelvin = Celsius + 273.15
Celsius = (5.0 / 9) * (Fahrenheit - 32)
For example, you might ask the user which kind of temperature he/she wants to enter, and then output the temperature in Kelvin, Fahrenheit, and Celsius.
Which kind of temperature would you like to enter (Kelvin (1), Fahrenheit(2), or Celsius(3))? 1
Enter your temperature: 20.0
Your temperature in Kelvin is 20.
Your temperature in Celsius is -253.15.
Your temperature in Fahrenheit is -423.67.