Find Jobs
Hire Freelancers

Classes

$5-10 USD

Concluído
Publicado há mais de 20 anos

$5-10 USD

Pago na entrega
Has to be completed and working by Saturday Dec 6. I will email the .cpp files stipulated in assignment. Assignment #6 - Classes 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) 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 emacs. g32 compiler
ID do Projeto: 3026659

Sobre o projeto

3 propostas
Projeto remoto
Ativo há 20 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
Concedido a:
Avatar do Usuário
See private message.
$7 USD em 2 dias
4,9 (79 avaliações)
4,7
4,7
3 freelancers estão ofertando em média $7 USD for esse trabalho
Avatar do Usuário
See private message.
$6,80 USD em 2 dias
4,9 (147 avaliações)
6,5
6,5
Avatar do Usuário
See private message.
$8,50 USD em 2 dias
4,9 (3 avaliações)
1,4
1,4

Sobre o cliente

Bandeira do(a) UNITED STATES
United States
5,0
2
Membro desde nov. 20, 2003

Verificação do Cliente

Outros trabalhos deste cliente

Arrays and sorting
$5-10 USD
Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.