Hi Guys and Girls,
Just started C++ not long ago, and I want to make a console app based calculator to test my new knowledge. To save a whole heap of coding I'm going to try and use a repeat... let me explain in detail...
When you start the app there is the welcome message etc
Then after pressing enter you get to the actual calculator...
It starts by asking you how many numbers your going to work with - this will generate the amount of times to repeat the code...
Now, this is what happens...
The calculator shows a message saying "Number: " and then "1" (this changes as you go on) Then it minuses/pluses the repeat operators... then loops.
What I'd like it to do is:
Say Number: #
Then create a variable called number1
Take an input for variable number1
(The rest I can deal with... getting and input for an operator eg + or - or *)
... Then Repeat
Saving the variable number1 and replacing it with variable number2
That's where the generation of variables comes in...
(If you can show me the concept I'll adapt it for the operators)
I hope that's clear enough... if not please say... I'll be truly greatful if someone helps as I'm teaching myself and there is no one to turn to.
Thanks.
Oh and this is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
/*
calc_rev2
*/
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
//Introduction stuff here (left it out for now...
//Start of calc - check how many number will be used...
int operationamount;
cout << "How many numbers will be used in you calculation?\n";
cin >> operationamount;
//loop to collect variables
int numcount = 1;
while (operationamount > 0)
{
cout << "\nNumber" << numcount << ": " << "\n";
//need my generation of variables and cin code here?!?!?
operationamount = operationamount - 1;
numcount = numcount + 1;
}
//end
system("PAUSE");
return 0;
}
|
Once again thanks if you can either help me or lead me in the right direction (links to help)..
Please also let me know if I'm doing any bad habits in the code above...
I heard something about system("PAUSE") not being good... I'm not sure...