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

  Sectors on the physical device

For any volume(s) situated on the EnCE Hard Drive, answer the following questions by writing question number and answer within a Notes Bookmark. Keep the Notes Bookmark within the bookmark folder created for that volume. Specify how many sectors a..

  Relational algebra tree for queries

Sketch a relational algebra tree (RAT) for each of queries and use the heuristic rules to convert the queries into a more efficient form. Describe each step and state any transformation rules utilized in the process.

  Security policy document project

Analyze security requirements and develop a security policy

  How to maintain the list of cd/dvds

How to maintain the list of CD/DVDs.

  Recognize how to locate fsmo roles

Recognize how to locate FSMO roles?

  Explain the design for the memory subsystem

Explain the design for the memory subsystem

  Research for a voip solution

In the future, Klamath’s separate the voice network will be dismantled. All the voice, data, and video traffic will traverse Metro Ethernet network.

  Using schedule performance index

Use the CPI to determine the estimate at completion (EAC) for this project. Describe whether project is performing better or worse than planned? Use the schedule performance index (SPI) to estimate how long ~ will take in order to finish this proje..

  What is the significance of optimizing the design

What is the significance of optimizing the design

  Why is an object (oop) a module

Why is an object (OOP) a module

  Utilizing automatic end-of-file logic to signal end of input

Design an algorithm to compute and print the average earnings, lowest earnings, and the highest earnings of a group of employees. Every input record will consists of name and earnings of one employee.

  Purpose and use of the java adapter classes

Purpose and use of the Java Adapter classes

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