Hey all, I am fairly new with C++ and I registered here to ask for suggestions on how I can create my project.

I proposed to my professor that I will create a scientific calculator with "additional functions". By additional functions I mean like a SC with that can solve the missing side of a right triangle with the pythagorean theorem, an SC that can convert values to various english measurements, and other stuff that I can think about. Another thing that I added is that I will create a calculator that can convert any decimal value to hecadecimal, binary and octal.

But now I can't seem to think how can I start this. I have thought of using switches and functions to distinguish each operation to be used. I already stated in my proposal that my calculator can only do one operation at a time and my professor accepted that fact. So what can I do to exclude each and every function?

I have also thought about like saving the value computed and then the user can choose what to operation to use next on the newly acquired value.

Even though my professor approved my proposal he exclaimed that my calculator should include graphics and sound effects, how can I do that? The only thing that I thought for graphics is to cout a layout of some sort. And about the sound thing the beep is the only one I can think of.

So far we have only studied up to functions (but I think we will be only learning up to arrays by the end of this term). What we have tackled so far is:

basic cin and cout
if and else statements
switches
loops
functions

That's all of it. All very basic.

Well, that's all. Hope I didn't bore you or anything. Thank you so much for reading and any help and suggestions on how I can create this program will surely be appreciated. Thank you and good day!

Recommended Answers

All 19 Replies

So, let me get this straight: you told your prof that you will write a program that you have no clue how to write??? Like biting off more than you can chew?

On a scale of 0 to 100% how well do you know c++ or c ? Are you taking intro, intermediate, or advanced class ?

For the graphics I suppose wxWidgets might be the best way to go because its portable to most compilers and at least three operating systems that I know of. But wxWidgets will require a firm understanding of C language.

i suggest making a program for every function first, and then making a program that runs the programs when you write something in it

So, let me get this straight: you told your prof that you will write a program that you have no clue how to write??? Like biting off more than you can chew?

On a scale of 0 to 100% how well do you know c++ or c ? Are you taking intro, intermediate, or advanced class ?

For the graphics I suppose wxWidgets might be the best way to go because its portable to most compilers and at least three operating systems that I know of. But wxWidgets will require a firm understanding of C language.

I somehow had the idea I can use switch statements in sorting out each operator for the calculator. I'm sorry if I sound like I was biting more off than I can chew. Our professor did say try making a program that exceeds our limitations and I believe that is what I would like to do (sort of).

I am talking an intro class on C++ and on a scale of 0 - 100 for an intro class I can say I'm an 85%

You need to learn postfix notation and use a stack to evaluate an expression , kerninghan and rithie C book has got code for basic calculator.

You need to learn postfix notation and use a stack to evaluate an expression , kerninghan and rithie C book has got code for basic calculator.

as the way you speaks you know nothing about C++ right ? you know C up to now.So that ithelp's C book will do the best for you and I recommand it.

Anyhow it's not a free book. Anyway if you can manage the C++
anyway , then use this book , it have a project similar to that.
http://www.relisoft.com/book/
this book is one of a recommended book in our main book list.( daniweb's C++ book thread).And before you start I'm warned you
this book requires C++ knowledge, but you can freely read it.

Good thing you proposed a challenging project. You will learn much more this way and your knowledge base will increase considerably. Don't be bothered about "biting off more than you can chew" ... u will choke, and then you will swallow , with pain, and you will be the wiser for it.

There is a vast ocean of resource available online to teach you all about C++ graphics and multimedia. just google well and all shall be disclosed. For starters practice functions well and get to know arrays well. and then you should be 50% there. My Best wishes!

A Wonderful book on C++ is Bruce Eckel's Thinking in C++ , its free for download and will teach u all u need.

Good thing you proposed a challenging project. You will learn much more this way and your knowledge base will increase considerably. Don't be bothered about "biting off more than you can chew" ... u will choke, and then you will swallow , with pain, and you will be the wiser for it.

If he has all the time in the world I might agree. But there is a short time constraint -- I suppose the assignment has to be turned in before the class ends.

Hey all, I was trying to make a decimal to binary converter for this calculator project of mine without using the math library and I came up with this:

#include <iostream>
using namespace std;

int main(void)
{
    int num, ctr1, ctr2, divide, bin[100];
    
    cout<<"Enter Number: ";
    cin>>num;
    
    cout<<"\nThe binary equivalent is: \n";
    
    for (ctr1=0;num=0;ctr1++)
    {
        divide = num%2;
        bin[ctr1] = divide;
        num = (num/2);
    }
    
    for (ctr2=0;num>=0;ctr2--)
    {
        cout<<bin[ctr2];
    }
    
    system("pause");
}

Only problem of mine now is, it displays an indefinite loop! I don't know where I went wrong though. Can someone please point out to me what I have done wrong? I believe it is during the array storage part.

I am using devc++ since visual c++ express is so confusing and visual studio is well, um expensive. Thanks!

for (ctr2=0;num>=0;ctr2--)
    {
        cout<<bin[ctr2];
    }

fault in your for loop. its telling :
initialize ctrl2 to 0, decrement it every time by 1, run the loop till num>=0 .
So always num >=0 , as its unchanging in the loop. hence it runs for infinite.

Ahh I see, that was kind of stupid. I edited it now, no more indefinite loops but the output is wrong. Here is what I tried out:

for (ctr2=0;ctr2>=0;ctr2--)

I really need to get this down so that I can create a dec - bin, dec- oct and dec - hex converter for the calculator.

So far what I have only done is the basic mdas, and I am now thinking of adding trigo functions using cmath (I can't comprehend the logic on how to create my own sine, cosine and tangent functions LOL).

Ahh I see, that was kind of stupid. I edited it now, no more indefinite loops but the output is wrong. Here is what I tried out:

for (ctr2=0;ctr2>=0;ctr2--)

I really need to get this down so that I can create a dec - bin, dec- oct and dec - hex converter for the calculator.

So far what I have only done is the basic mdas, and I am now thinking of adding trigo functions using cmath (I can't comprehend the logic on how to create my own sine, cosine and tangent functions LOL).

for (ctr2=0;ctr2>=0;ctr2--)

Now what have you done here ? You are saying to the loop ...

Initialize ctrl2 to 0, decrement it by 1 every time, run the loop till its greater than or equal to 0 ........ ??? It will run the loop exactly 1ce!!

As everytime the the 2nd time loop is about to run it fails the condition ctrl2 >=0.

You need to think and code how to display an array in reverse.

Hint: wrong intitialization in this 2nd for loop.

how about this?

for (ctr2=ctr1;ctr2>=0;ctr2--)

Getting close?

Close. But still it will give wrong output. I will drop a hint.

for(int i=0;i<=5;i++)
{
//something goes in here...
}
cout>>i;

guess what is the output of i ?

And similarly whats the value of ctr1 when it comes out of the 1st loop.

Is that the value you want ctr2 to be initialized to ? ;)

I get it now! On your hint it will output 6 so in my code ctr2 = ctr1 - 1 because if I just put ctr2 = ctr2 the first value it will access during display will be a garbage value!

May I ask something else now? Because I plan on adding a converter thing on my calculator, and so far the only thing I have done is a meters to yard converter haha. I initially planned on making a converter for the most common lenght conversions (cm -m, feet - cm, etc.) but I can't think of any other way to do this without typing in too much code!

What I have thought is that the user should enter comething like cin>>digit>>unit>>unittobeconverted

but with something like that I'd have to make functions or cases for each and every conversion like one for cm-m, cm-ft, etc. Is there any other way to do this? I want to optimize my code but I don't know how!

Thanks to those who'll be suggesting stuff.

>>I'd have to make functions or cases for each and every conversion like one for cm-m, cm-ft, etc. Is there any other way to do this?

Sometimes the buttons can be used for different purposes depending on the state of the button or combination of buttons pushed or sequence of buttons pushed, but I don't see any way around the need to have code for each conversion, math function, etc that you want to do unless you want the user to do it on their own.

I see, so there is really no way but to code it one by one, (ulp) that is too tedious considering I would have to pass this next week thursday. I still don't have the graphics and sound thing.

Can you guys suggest any more features that I can add unto the calculator just in case? I can't emulate some of the functions on the real scientific calculator but I do hope to make extra features that aren't on the sci cal to make up for it.

Close. But still it will give wrong output. I will drop a hint.

for(int i=0;i<=5;i++)
{
//something goes in here...
}
cout>>i;

guess what is the output of i ?

I'll take a guess: Compiler error. :icon_wink:
You probably meant: cout [B]<<[/B] i;

Ulp the firm understanding thing, I don't have that yet and I don't have the time to establish that since this will be passed next week thursday. I was thinking of ouputting a calculator shaped box through the use of cout only. Does dev c++ support the goto(x,y) thing like in turbo c++? haven't tried it yet cause I am still having troubles for the conversions thing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.