Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Class number (add subtract divide and multiply

Reply
Thread Tools

Class number (add subtract divide and multiply

 
 
gavinstone007@gmail.com
Guest
Posts: n/a
 
      10-13-2006
Who can solve this?

Wrte a class number which represents all numbers. Implement member
functions to carry out the following arithmetic operations on class
instances, add- which returns an object of class number whose value is
the sum of the numbers added, subtract- returns an object of class
number and value is the result subtracting the second number object
from the first, multiply and divide (the return formats are the same as
for add and subtract). Provide a suitable user interface for your
program.


Have fun guys

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      10-13-2006
* http://www.velocityreviews.com/forums/(E-Mail Removed):
> Who can solve this?
>
> Wrte a class number which represents all numbers. Implement member
> functions to carry out the following arithmetic operations on class
> instances, add- which returns an object of class number whose value is
> the sum of the numbers added, subtract- returns an object of class
> number and value is the result subtracting the second number object
> from the first, multiply and divide (the return formats are the same as
> for add and subtract). Provide a suitable user interface for your
> program.


There's a ready-made solution in the FAQ, no need to look further.

<url: http://tinyurl.com/o5zw9>

Hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
 
Peter Jansson
Guest
Posts: n/a
 
      10-13-2006
(E-Mail Removed) wrote:
> Who can solve this?
>
> Wrte a class number which represents all numbers. Implement member
> functions to carry out the following arithmetic operations on class
> instances, add- which returns an object of class number whose value is
> the sum of the numbers added, subtract- returns an object of class
> number and value is the result subtracting the second number object
> from the first, multiply and divide (the return formats are the same as
> for add and subtract). Provide a suitable user interface for your
> program.
>
>
> Have fun guys
>


Perhaps you can try? Or else tell your teacher (I assume it is homework)
that you are not up to it... I.e. we will not do your homework for you.


Sincerely,

Peter Jansson
http://www.p-jansson.com/
http://www.jansson.net/
 
Reply With Quote
 
Howard
Guest
Posts: n/a
 
      10-13-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Who can solve this?
>
> Wrte a class number which represents all numbers.



Not possible. There is no way to represent "all numbers" on a computer with
finite resources. Assuming you mean integers: if you take the largest
possible integer representable using all the bits of your entire memory,
there exists a number larger than that. This number cannot be represented
on your computer, because you don't have enough bits. Likewise, if you're
talking about floating-point numbers (reals), then there exist an infinity
of numbers for which no exact representation is possible, only
approximations. Pi, for example.

But somehow I doubt that's the answer your instructor is looking for.

To correctly follow his/her instructions, might I suggest you do what he/she
says, and "write" the class instead of asking someone else to do so?

-H





 
Reply With Quote
 
jjds101@yahoo.com
Guest
Posts: n/a
 
      10-13-2006

(E-Mail Removed) wrote:
> Who can solve this?
>
> Wrte a class number which represents all numbers. Implement member
> functions to carry out the following arithmetic operations on class
> instances, add- which returns an object of class number whose value is
> the sum of the numbers added, subtract- returns an object of class
> number and value is the result subtracting the second number object
> from the first, multiply and divide (the return formats are the same as
> for add and subtract). Provide a suitable user interface for your
> program.
>
>
> Have fun guys


#include <fstream>

class numbers {
int num1;

public:
numbers() { num1 = 0; }
void add(int x) {
std:fstream os;
os.open("a");
while(1) {
num1+=x;
os << num1;
}
}
};

int main() {
numbers n;
n.add(2);
return 0;
}

 
Reply With Quote
 
Walter Bright
Guest
Posts: n/a
 
      10-13-2006
(E-Mail Removed) wrote:
> Who can solve this?
>
> Wrte a class number which represents all numbers. Implement member
> functions to carry out the following arithmetic operations on class
> instances, add- which returns an object of class number whose value is
> the sum of the numbers added, subtract- returns an object of class
> number and value is the result subtracting the second number object
> from the first, multiply and divide (the return formats are the same as
> for add and subtract). Provide a suitable user interface for your
> program.
>
>
> Have fun guys


You could try handing this one in:

#include <stdio.h>

class Number
{
public:
Number& operator/(Number& n) { printf("assignment\n"); return n; }
Number& operator-(Number& n) { printf("an F for "); return n; }
Number& operator+(Number& n) { printf("I deserve "); return n; }
Number& operator*(Number& n) { printf("this "); return n; }
};

int main(int argc, char **argv)
{
class Number n;

(n + n - n) * n / n;
return 0;
}
 
Reply With Quote
 
Frederick Gotham
Guest
Posts: n/a
 
      10-13-2006
Gavin posted:

> Wrte a class number which represents all numbers.



879.


> Have fun guys



With your mother? I'd love too... but I have had my vaccinations.

--

Frederick Gotham
 
Reply With Quote
 
Tom Smith
Guest
Posts: n/a
 
      10-13-2006
(E-Mail Removed) wrote:
> Who can solve this?
>
> Wrte a class number which represents all numbers. Implement member
> functions to carry out the following arithmetic operations on class
> instances, add- which returns an object of class number whose value is
> the sum of the numbers added, subtract- returns an object of class
> number and value is the result subtracting the second number object
> from the first, multiply and divide (the return formats are the same as
> for add and subtract). Provide a suitable user interface for your
> program.
>
>
> Have fun guys
>


int. long might also work.

you have fun too -

Tom
 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      10-14-2006
<(E-Mail Removed)> wrote:

> Who can solve this?
>
> Wrte a class number which represents all numbers. Implement member
> functions to carry out the following arithmetic operations on class
> instances, add- which returns an object of class number whose value is
> the sum of the numbers added, subtract- returns an object of class
> number and value is the result subtracting the second number object
> from the first, multiply and divide (the return formats are the same as
> for add and subtract). Provide a suitable user interface for your
> program.
>
>
> Have fun guys


You just might have better luck getting useful answers if you didn't presume
the people you wanted help from were not a bunch of bumpkins who just fell
off the turnip truck.

There is no challenge here but it is likely to take a lot of time. I would
start by asking the instructor if you could restrict the solution to real
numbers. If he is really nice, he might even let you restrict it to
integers.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there an algorithm for integer multiply and divide at the same time? Default User C++ 16 07-03-2008 08:15 AM
NEED HELP: multiply and divide with integer in VHDL ledinhkha@gmail.com VHDL 2 12-15-2005 08:06 AM
Multiply/Divide a float with a power of two per.nordlow@gmail.com C Programming 5 09-01-2005 09:53 PM
Bit-shifting to multiply and divide? Nobody C++ 6 11-15-2004 08:55 AM
GregorianCalendar and how to subtract MONTH from a date. Manoj Nair Java 4 09-04-2003 05:49 AM



Advertisments