Performing calculations through class

Assignment Help Computer Engineering
Reference no: EM1318299

Build a class known as Rational for carrying out the arithmetic with fractions. Write down a driver program in order to test your class.

Utilize the integer variables in order to represent private instance variables of the class—the numerator and the denominator. Provide a constructor method that allows an objet of this class to be initialized at the time it is declared. The constructor must store fraction in decreased form (that is, the fraction 2/4 would be stored within the object as 1 in the numerator and 2 in the denominator). Give a no argument constructor with the default values in case no initializes are offered. Give public methods for each of the following:

a) Addition of the two Rational numbers. Result of addition must be stored in reduced form.

b) Subtraction of the two Rational numbers. The result of subtraction must be stored in reduced form.

c) Multiplication of the two Rational numbers. The result of multiplication should be stored in reduced form.

d) Division of the two Rational numbers. The result of division must be stored in reduced form.

e) Printing Rational numbers in form a/b, where a is the numerator and b is the denominator.

f) Printing the Rational numbers in floating-point format. (Consider providing the formatting capabilities which allow the user of class to specify number of digits of precision to the right of the decimal point.)

Reference no: EM1318299

Questions Cloud

Evaluate an amount of gravel from the given ratio : Evaluate an amount of gravel from the given ratio - How much gravel and sand should he add to make concrete?
Hypothesis test by using critical value approach : Assume a population standard deviation of $2.40 per hour and compute the p-value. c. With a = .05 as the level of significance, what is your conclusion? d. Repeat the preceding hypothesis test using the critical value approach.
Write a simplified expression for the weekly revenue : Write a simplified expression for the weekly revenue and Construct a table of values and graph the function
Make the solutions that can be read from the simplex tableau : Make the solutions that can be read from the simplex tableau
Performing calculations through class : Build a class known as Rational for carrying out the arithmetic with fractions. Write down a driver program in order to test your class. Addition of the two Rational numbers. Result of addition must be stored in reduced form.
Prepare a table of values and graph the function : Find the maximum height of arrow using given function and prepare a table of values and graph the function
Neutral and failing to engage : Ruth carelessly parks her car on a steep hill, leaving the car in neutral and failing to engage the parking brake. The car rolls down the hill, knocking down an electric line. This sparks from the broken line ignite a grass fire.
Test whether music reduces studying capacity : Test whether the music reduces studying capacity at a .05 level of significance.
Determining critical value of chi-square : What will be critical value of chi-square if test is to be performed at 0.025 level?  At the 0.05 level?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Problems on b tree

Problems on B tree

  Regarding level of order traversal

Write down a level order traversal that does every level of the binary tree before moving on to the next level. Starting with the root add the children nodes to list.

  Illustrate decryption equation

Illustrate decryption equation.

  Wda wireless device application business models

Write down a 2.5 - 3 page paper comparing the WDA wireless device application business models utilized by Sprint, Verizon, and AT&T Wireless.

  What are pros and cons of society''s increasing reliance data

What are pros and cons of society's increasing reliance data

  Challenges of internet search

State different challenges of relying over the Internet for your research?In extending a single-system mail system to distributed mail system, state the key additions which should be involved? Discuss in scholarly detail.

  How to name the associative entities

How to name the associative entities

  Explaining dynamic programming approach

Assume we have a directed the acyclic graph G = (V,E) with the real-valued edge weights and two distinguished vertices s and t.

  What is mflops rating of the system

What is MFLOPS rating of the system

  Describe disparity between vulnerability, threat and control

Describe disparity between vulnerability, threat and control

  Purpose of testing

Describe the purpose of testing. Discuss how tests are carried out at different levels within the system.

  Internet protocol-version 4 and version 6

Explain why do we require a new Internet protocol? Compare and contrast the version 4 and version 6.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd