Find Jobs
Hire Freelancers

Personal Project Assignment

$5-10 USD

Lukket
Slået op næsten 20 år siden

$5-10 USD

Betales ved levering
1. Purpose: To gain experience using classes. 2. The Problem (an enhanced version of Chapter 11, Programming Problem 3, page 659): design, implement, and test a Rational class that represents a rational number as a pair of integers instead of a single floating-point number. 3. More Details: A rational number is a number that can be expressed as a fraction whose numerator and denominator are integers. Examples of rational numbers are 0.75 (which is 3/4) and 1.125 (which is 9/8). The value p is not a rational number; it cannot be expressed as the ratio of two integers. The Rational objects must be stored in their reduced form. In other words, the rational number 12/16 should be stored as 3/4. A private member function Reduce should be provided to reduce the Rational object. The Rational class should have two class constructors. The first one lets the client specify an initial numerator and denominator. The other??"the default constructor??"creates the Rational number 0, represented as a numerator of 0 and a denominator of 1. The Rational class should have arithmetic operations that add, subtract, multiply, and divide two Rational objects. These should be implemented as value-returning functions, each returning a Rational object. The Rational class should have a Boolean operation that compares two Rational objects for equality. The Rational class should have an input operation that reads a rational number from a designated input stream in the form numerator/denominator. The Rational class should have an output operation that writes a rational number out to a designated output stream in the form numerator/denominator. ## Deliverables 4. Program Structures You are required to deploy "separate compilation," otherwise known as multi-file program development, which means that your program will reside in more than one source file. You must provide exactly three files for this project. All three files have been started for you but you must complete them as instructed below. In fact, the collection of files that have been provided are fully compilable, linkable, and executable with no warning or error messages. The user interface is completely functional but none of the rational number arithmetic has been implemented. DO NOT rename the files. The file names for this project are strictly defined and must not be altered. Click on the three hyperlinked file names below to view and download each file. . rational.h is the specification file and contains the definition of Rational class. This file is complete and requires no addition or modification. However, you ARE allowed to ADD (and only ADD) member functions to the class definition if you wish to do so [login to view URL] is the implementation file and must contain the implementation of Rational class member functions and any other supporting function. This file contains several provided functions but you must complete the file by adding the remaining Rational class member functions. There are two particular functions that will come in handy for this project. These functions (gcd and Reduce) are used to reduce a rational number to its smallest form. For example, a fraction 12/16 can be converted to 3/4 using these functions. The functions are provided in their entirety in the [login to view URL] file. There are two other functions provided in their entirety: the class default constructor and the function Read. [login to view URL] is the client file and contains function main and other supporting functions that are needed to use and, in this case, to test the functionality of the Rational class. This file is the test driver for Rational class and has already been started for you so that you have a basic menu-driven functionality. You must add the client code that uses the Rational class to allow the user full testing capability for your implementation. You must only fill the areas where it has been indicated "To be done by student." All required functions have been provided and no new functions are needed in this file. The student must only complete the main function. 5. Error Checking: Rational class member functions should check for a zero denominator and abort the program using the assert function if zero is input or formed in a calculation for the denominator. The client code must try to avoid operations that may result in a zero denominator Rational object. For example, the client code should not allow a rational number to be divided by another rational number of zero value. 11. Output: This test driver works with up to two fractions acting as operands for various operations. These operands are left and right operands of an arithmetic operation. Let's call the operands "LEFT" and "RIGHT". LEFT = RIGHT = Enter the character in (parentheses) to choose an operation: (+) Add LEFT and RIGHT (-) Subtract RIGHT from LEFT (*) Multiply LEFT by RIGHT (/) Divide LEFT by RIGHT (L) read LEFT (R) read RIGHT (=) is LEFT equal to RIGHT? (S) swap LEFT and RIGHT (?) display this menu (Q)quit program Enter choice: 1) 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request. 3) Exclusive and complete copyrights to all work purchased. (No GPL, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site). ## Platform Operating System: Windows 2000/XP Microsoft Windows Visual C++ 6.0 I will email the .cpp files stipulated in assignment.
Projekt-ID: 3196942

Om projektet

2 forslag
Projekt på afstand
Aktiv 20 år siden

Leder du efter muligheder for at tjene penge?

Fordele ved budafgivning på Freelancer

Fastsæt dit budget og din tidsramme
Bliv betalt for dit arbejde
Oprids dit forslag
Det er gratis at skrive sig op og byde på jobs
2 freelancere byder i gennemsnit $7 USD på dette job
Brug Avatar.
See private message.
$6,38 USD på 1 dag
5,0 (39 anmeldelser)
3,5
3,5
Brug Avatar.
See private message.
$7,65 USD på 1 dag
4,8 (10 anmeldelser)
2,8
2,8

Om klienten

Flag for UNITED STATES
United States
5,0
1
Medlem siden maj 1, 2004

Klientverificering

Tak! Vi har sendt dig en e-mail med et link, så du kan modtage din kredit.
Noget gik galt, da vi forsøgte at sende din mail. Prøv venligst igen.
Registrerede brugere Oprettede jobs i alt
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Indlæser forhåndsvisning
Geolokalisering er tilladt.
Din session er udløbet, og du er blevet logget ud. Log venligst ind igen.