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

  Developing an eer schema for database application

Develop an EER schema for a database application which you are interested in. State all the constraints which should hold on the database.

  Plan an er diagram

Plan an ER diagram

  Generate a work breakdown structure code

Generate a Work Breakdown Structure Code

  What do you mean by pseudocode and case subroutine call

What do you mean by pseudocode and case Subroutine call

  Federal rules and criminal codes

Think about computer forensics professional’s testimony preparations, and how the investigator must ensure that the federal rules and criminal codes are followed both during and after the completion of the investigation. Identify and discuss some ..

  Develop a checkout lane simulation

Develop a checkout lane simulation that can be used to determine the optimal number of lanes that Cougar Mart should have open.

  Object oriented design of a class

Object oriented design to develop a parent class known as Book which will receive the ISBN, author, title and price of book and select and print the details of all books with the price of more than $50.00.

  Write a java program that uses a two-dimensional array

Write a Java program that uses a two-dimensional array

  How to store ten floating-point values into vector

How to store ten floating-point values into vector. Write down a program that declares a vector of ten floating-point values

  How to make an xml file in visual studio

How to make an xml file in Visual Studio

  Organizational information processing theory

What is organizational information processing theory, explain its concepts and what do you meant by creating the slack resource, make the lateral relationship.

  Detail advantages of looping

Detail advantages of looping

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