Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone.
How to make this homework please
I want to build a calculator to prove the following properties for a given :
1: Associative
2: Commutative

Foe example: I want to give the program 2A+B-2 and when I click (isASSOIATIVE) button,
it will give me this:

(A*B)=2A+B-2
(A*B)*C=(2A+B-2)+C-2
=2A+B+C-4
A*(B*C)=2A+(2B+C-2)-2
=2A+2B+C-4

->A*(B*C) doesn't equal A*(B*C)
Not associative.
Posted
Updated 16-Jan-15 22:38pm
v3
Comments
OriginalGriff 17-Jan-15 4:36am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
enhzflep 17-Jan-15 4:39am    
That's just what I was about to say!
OriginalGriff 17-Jan-15 4:40am    
He's not off to a good start, is he? :laugh:
enhzflep 17-Jan-15 4:45am    
Oh I don't know - I think he's got his sights set on the future..
Why else would he be leaving so much room for improvement? :smirk:
Sergey Alexandrovich Kryukov 17-Jan-15 4:44am    
It makes sense only if all those A, B are not numbers.
—SA

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
It makes sense only if these objects are not numbers (for numbers, these algebraic properties are proven in the theory of arithmetic :-)). Here is what you need:
  1. Define the object type of you algebra;
  2. Define the algebraic operations '*', '+' and '-'; it's the best to use operator overloading;
  3. Develop the equivalence (equality functions); it's good to define '=' and '<>' comparison operators;
  4. Use all of the above in your tests.


This is what you need to use:
http://msdn.microsoft.com/en-us/library/bsc2ak47(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.object.gethashcode(v=vs.110).aspx[^] (required if you override Equals),
http://msdn.microsoft.com/en-us/library/system.object.referenceequals(v=vs.110).aspx[^] (needed for implementation of Equals, to avoid "infinite" recursion when comparing references),
http://msdn.microsoft.com/en-us/library/scs11cxx.aspx[^].

—SA
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900