I am a fifteen year old trying to learn c++ to program a scientific calculator that is simpler to use. Would it be okay if I asked for advice on different problems I am having with the calculator and how to program certain things on it without providing a code? (I don't have a code, but I need help.) It is not a regular calculator, I was going to list the different things out to the users and show symbols to the user to use the calculator. My first question is what specific areas should I look into the most? Also are their any website tutorials that can help? (I have used Google but it remains ineffective). Please understand I am not asking anyone to do my work for me, I just really need help.

Hello

2 advices for you
1. You should break your question in several lines.
2. Providing code leads to better and faster replies.

But since you are only thinking at the moment it is all right.

It is not clear whether you are building a GUI or a simple text based program. But since you seem to be new, it must be latter.

And for a text based program, you will not face much trouble.

lastly, get yourself a book on c++ and write simple programs before moving onto big things.

Vinayak
Happy New Year

Would it be okay if I asked for advice on different problems I am having with the calculator and how to program certain things on it without providing a code?

Those kinds of questions are tricky to ask right. As long as you keep it on a conceptual level and don't give the impression that you want someone else to write the code for you, it should be fine.

I have used Google but it remains ineffective

I've found Google to be ineffective, but only very rarely. What search strings were you using?

I have two c++ books, but I do not understand most of the material in them.

The things I try to Google are probably just to general. For example, before last night I had to google something along the lines of have to declare a variable, luckily I was able to realize it and how stupid I was being.

I would like to make my program a GUI, but seeing as how I am a beginner and I have less than a week to learn how to program with c++, I think I will just make a text based programs.

Their is a basic calculator code in my book I was thinking of basing my program off of, what subjects should I focus on to be able to make my own scientific calculator?

By the way, the code for calculator I am basing my science fair project is:

#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int nNumberofArgs,  char* pszArgs[])
{
int nOperand1;
int nOperand2;
char cOperator;
cout << "Enter 'value1 op value2'/n"<< where op is +, -, *, / or % :" << end1;
cin >> nOperand1 << cOperator >> nOperand2;

cout << nOperand1,, " "<< cOperator << " "<< nOperand2 << " = ";

switch (cOperator)
{
case '+':
cout << nOperand1 + nOperand2;
break;
case '-':
cout << nOperand1 - nOperand2;
break;
case '*':
case 'x':
case 'X':
cout << nOperand 1 8 nOperand2;
case '/':
cout << nOperand1 / nOperand2;
break;
case '%":
cout << nOperand1 % nOperand2;
default:
cout << " is not understood";
}
cout << end1;

system ("PAUSE");
return 0;
}

I am sorry if I am not just supposed to type program codes in like that, but I could not figure out how to post in a different way.

My problem is that in even this basic program I do not understand what a few things are.

My first problem is what is a switch statement and what does it do in this program?

Why is there a break after each case (I know it changes the flow of control of the program but I am not clear how it changes it).

What does cout << ..; mean?

I am sorry if I sound like a annoying mooch, and I really appreciate the help.

Edited 5 Years Ago by Nick Evan: Added [CODE]-tags

My first problem is what is a switch statement and what does it do in this program?

Why is there a break after each case (I know it changes the flow of control of the program but I am not clear how it changes it).

What does cout << ..; mean?

You don't sound like an annoying mooch, but you can google just as well as we can. However, even just googling "cout" brings up 3-4 good links (google ignores punctuation, etc. so the "<<" part has no effect). Certainly googling "C++ tutorial" should get you a few pages worth of introductory material. The other thing is, since this is your science project (and even if it weren't) experiment with different lines of code to see how they behave.

lastly, get yourself a book on c++ and write simple programs before moving onto big things.

is spot on. Simple programs means really simple. Print something to the screen in one, add 2 numbers in another then print them to the screen, etc.

I am a fifteen year old trying to learn c++ to program a scientific calculator that is simpler to use. Would it be okay if I asked for advice on different problems I am having with the calculator and how to program certain things on it without providing a code? (I don't have a code, but I need help.) It is not a regular calculator, I was going to list the different things out to the users and show symbols to the user to use the calculator. My first question is what specific areas should I look into the most? Also are their any website tutorials that can help? (I have used Google but it remains ineffective). Please understand I am not asking anyone to do my work for me, I just really need help.

C++ (Programming – Principles and Practice using C++) is a really great book, I hope this will help you.

Ok sorry I did not know my post came out like that and I could not edit it at this point.

I have used google and I am about 220 pages into my c++ books, and things are making much more sense. I am sorry I asked stupid question, I let myself panic and all reason failed. Tomorrow I might ask more questions that I couldn't find an answer to anywhere, but I want to make sure I can't find the answers to my questions before I post again.

Thanks again.

Now you seem to be on the right path.

And for your calculator following areas are of importance
1.math header file
2.floating number operations possible error
3.Divide by zero error

cout is all right but u may consider printf for better control over formatting. I personaly prefer printf.
Good Luck

but u may consider printf

No. This is the C++ forum, not the C forum. The OP is on the right track at the moment, don't confuse him.

Edited 5 Years Ago by Nick Evan: n/a

Comments
Nothing to do with this post, but I wanted to give Nick Evan +points for keeping a lid on the spammers.

cout is all right but u may consider printf for better control over formatting.

printf doesn't offer control over cout, it offers brevity. The iostreams library is quite a bit more powerful, but also more verbose for any non-trivial formatting.

Yeah, speaking of printf in c++ forum was foolish of me.

Only the C++ purists will agree with that. printf is a perfectly viable option in C++, but it's important to recognize the limitations of your options so that you can choose them wisely.

This article has been dead for over six months. Start a new discussion instead.