Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Assignment #5

Similar presentations


Presentation on theme: "Programming Assignment #5"— Presentation transcript:

1 Programming Assignment #5
Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan and Ritchie, Absolute C++, by Walter Savitch, The C++ Programming Language, Special Edition, by Bjarne Stroustrup, and from C: How to Program, 5th and 6th editions, by Deitel and Deitel) CS-2303, A-Term 2012 Programming Assignment #5

2 Programming Assignment #5
Define and develop a class of rational numbers Overloaded operators for manipulating them +, –, *, /, ==, !=, <, <=, >, >= Overloaded << and >> operators for reading in from or writing out to streams Overloaded assignment operator to assign to a double A copy constructor, a default constructor, and two other constructors To make rational numbers from integers Create a test program to exercise this rational class. Scan in numbers and operations Execute them Print out the result in rational format and as a double CS-2303, A-Term 2012 Programming Assignment #5

3 What is a rational number
A number comprising two integers Numerator and denominator (Denominator may not be zero) Represent both as int I.e., 32-bit in Intel processors Do internal arithmetic in long long int i.e., 64-bit in Intel processors Always normalize! CS-2303, A-Term 2012 Programming Assignment #5

4 You may NOT refer to them! Programming Assignment #5
Notes There are many rational classes available on the web and in print. You may NOT refer to them! You must design and implement your own class and your own operators You may work alone or in two-person teams Project due at 11:59 PM, Sunday, September 30 CS-2303, A-Term 2012 Programming Assignment #5

5 Programming Assignment #5
Test program Command line arguments are one or more text files Each text file is a sequence of lines Each line consists of rational numbers of the form a/b c/d, etc., and operators such as +, -, *, /, ==, etc. All operations are expressed in postfix — e.g., 1/6 1/3 + 1/4 1/ * 3/4 6/8 == Result should be 1/2 Result should be 3/4 Result should be true CS-2303, A-Term 2012 Programming Assignment #5

6 Test Program (continued)
An arbitrary number of test files Each file an arbitrary number of lines Each line an arbitrary number of rational numbers and operations CS-2303, A-Term 2012 Programming Assignment #5

7 Programming Assignment #5
Test cases As many as you need to exercise your class … and test all operations different ways … using number with non-trivial denominators — including Denominators that are relatively prime Denominators that are large but not relatively prime CS-2303, A-Term 2012 Programming Assignment #5

8 Programming Assignment #5
Questions? CS-2303, A-Term 2012 Programming Assignment #5


Download ppt "Programming Assignment #5"

Similar presentations


Ads by Google