Thread: Rational Numbers

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    16

    Rational Numbers

    Hi, i have to create a program for school. I am not asking you to write it or even start it for me, but i am asking you to push me in the right direction so i know where to begin. We have to have the user input the numerator and denominator to create a fraction. They must create two fractions and they must be added, subtracted, timed, and divided. We are talking about objects, classes, structs, and etc. in class however, i dont understand this. What will be the puropse of objects and stuff in a program like this and how do i even begin? I only understand functions and stuff. I appericate the help

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    Well, you could have a Fraction class with both numerator and denominator as member variables and overload arithmetic operators to mimic math behavior.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    I was going to say something like what Desolation said, but also have a look at these links for classes and structures.

    Classes
    Structures

    When I first learned about classes (and still learning) I thought of them as collections of data types and functions that use those data types. Structures can be thought of as a collection of data types. There can be a lot more too them though, that's just an abstract look at it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rational Numbers Assignment Adding
    By CaliJoe in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2009, 11:37 PM
  2. Help with Rational Numbers (C++)
    By cloudjc in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2008, 04:03 PM
  3. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  4. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 11:15 AM
  5. How to deal with repeating rational numbers
    By carrja99 in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2002, 11:33 AM