Click here to Skip to main content
15,923,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ 4.2 smilie errors...help! Pin
shaveyourhead27-Jan-05 18:10
shaveyourhead27-Jan-05 18:10 
GeneralRe: C++ 4.2 smilie errors...help! Pin
Jim Crafton28-Jan-05 3:17
Jim Crafton28-Jan-05 3:17 
GeneralRe: C++ 4.2 smilie errors...help! - Problem Resolved. Thanks Pin
shaveyourhead28-Jan-05 5:28
shaveyourhead28-Jan-05 5:28 
GeneralSimple Calculator (Someone PLEASE HELP ME!!!!!) Pin
Atptour27-Jan-05 16:13
Atptour27-Jan-05 16:13 
GeneralRe: Simple Calculator (Someone PLEASE HELP ME!!!!!) Pin
Jim Crafton27-Jan-05 17:18
Jim Crafton27-Jan-05 17:18 
GeneralRe: Simple Calculator (Someone PLEASE HELP ME!!!!!) Pin
DHAPPREP27-Jan-05 17:55
DHAPPREP27-Jan-05 17:55 
GeneralRe: Simple Calculator (Someone PLEASE HELP ME!!!!!) Pin
David Crow28-Jan-05 3:12
David Crow28-Jan-05 3:12 
GeneralRe: Simple Calculator (Someone PLEASE HELP ME!!!!!) Pin
V.27-Jan-05 23:28
professionalV.27-Jan-05 23:28 
You got flamed, that's normal because no one likes to answer yet another homework question.

I will though, give you some hints to start of...
1. Define the class -- Calculator -> see your book, if you can't do this, don't even start.
a) Data members: Operand1, Operand2, and Answer -- all of type float. -> create three variables of type float, that should be do-able

b) Methods: Constructor, GetData, Add, Subtract, Multiply, Divide, and ShowAnswer -- all void return types. -> actually, C++ consists of functions, but anyway, a function does something with your variables. The constructor normally initializes your variables, I suspect GetData will analyze the input. (take in input, put the first number in operand1, the second in operand two and decide if you have to add/substract/... [EDIT]Reading further I see this is not the case, I have no idea what it should do[/EDIT]

c) Data members should be private, but all methods should be public -> who-ever tells you all functions should be public is a moron. Only make public those things that you want other classes to see. Constructor, GetData, Add, Subtract, Multiply, Divide, and ShowAnswer are good to make public in this case.

2. Constructor -- Calculator

a) The constructor should provide for two arguments of type float: Op1, and Op2
public Calculater(float Op1 = 0, float Op2 = 0){ ... }
b) Give default values of zero to Op1, and 1 to Op2 in case the user passes no arguments when objects are created. -> see a)

c) The constructor should assign the values of Op1 and Op2 to Operand1 and Operand2, respectively.-> I hope you can do this

3. Each method that does a calculation should store the answer in Answer but not do any output itself. Answer = Operand1 +,-,* or / Operand2

4. The ShowAnswer method is responsible for displaying the calculated result of the last calculation. -> that would be something like cout >> Answer= >> endl; // make it nicer then this

5. Create four objects, Problem1, Problem2, Problem3, and Problem4 as follows:

Calculator Problem1(3,7), Problem2(8,3), Problem3, Problem4(17,5);
->this will create your Object

6. Do the following method calls: (YOU MUST FOLLOW THESE INSTRUCTIONS!)

a) For Problem1, call the method that will add the default values, and call the method to display the result. Problem1.Add(); Problem1.ShowAnswer();

b) For Problem2, call the method that will subtract the default values, and call the method to display the result. -> cf a)

c) For Problem3, call the method to get data, provide values of 7 and 3, multiply them, and display results.-> cf a)

d) For Problem4, call the method that will divide the first operand by the second, and display the results.-> cf a)



You're extremely lucky I'm bored for the moment Smile | :) .
So: define your class, with all the functions, then call the class from your main.
If you succed, you can always try to input the numbers yourself, making an interactive calculator.

good luck.

"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
GeneralRe: Simple Calculator (Someone PLEASE HELP ME!!!!!) Pin
David Crow28-Jan-05 3:03
David Crow28-Jan-05 3:03 
GeneralRe: Simple Calculator (Someone PLEASE HELP ME!!!!!) Pin
David Crow28-Jan-05 3:02
David Crow28-Jan-05 3:02 
GeneralRe: Simple Calculator (Someone PLEASE HELP ME!!!!!) Pin
trelliot28-Jan-05 3:10
trelliot28-Jan-05 3:10 
GeneralWin32 EDIT Control Pin
Aneurysm0027-Jan-05 11:33
Aneurysm0027-Jan-05 11:33 
GeneralRe: Win32 EDIT Control Pin
Jim Crafton27-Jan-05 17:22
Jim Crafton27-Jan-05 17:22 
GeneralRe: Win32 EDIT Control Pin
Aneurysm0028-Jan-05 7:11
Aneurysm0028-Jan-05 7:11 
GeneralVS 7.1 On Windows XP Pin
Grahamfff27-Jan-05 10:57
Grahamfff27-Jan-05 10:57 
GeneralRe: VS 7.1 On Windows XP Pin
Christian Graus27-Jan-05 14:17
protectorChristian Graus27-Jan-05 14:17 
GeneralRe: VS 7.1 On Windows XP Pin
Jim Crafton27-Jan-05 17:10
Jim Crafton27-Jan-05 17:10 
GeneralRe: VS 7.1 On Windows XP Pin
rbid27-Jan-05 23:57
rbid27-Jan-05 23:57 
GeneralRe: VS 7.1 On Windows XP Pin
Grahamfff28-Jan-05 9:50
Grahamfff28-Jan-05 9:50 
Generalconvert double to char Pin
Sam197927-Jan-05 10:42
Sam197927-Jan-05 10:42 
GeneralRe: convert double to char Pin
Chris Losinger27-Jan-05 11:03
professionalChris Losinger27-Jan-05 11:03 
GeneralRe: convert double to char Pin
Jim Crafton27-Jan-05 17:07
Jim Crafton27-Jan-05 17:07 
GeneralRe: convert double to char Pin
trelliot27-Jan-05 13:16
trelliot27-Jan-05 13:16 
GeneralRe: convert double to char Pin
trelliot27-Jan-05 17:20
trelliot27-Jan-05 17:20 
GeneralRe: convert double to char Pin
JKallen27-Jan-05 17:32
JKallen27-Jan-05 17:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.