 |

11-30-2009, 06:08 PM
|
|
Member
|
|
Join Date: Aug 2007
Posts: 80
|
|
After 2 days of C++
Well my first project after 2 days of C++, any c&c appreciated.
Oh and I know using system() is bad programming.
Code:
/*
========================
-----Calculator V1------
========================
- Created in Visual C++ -
========================
*/
#include "stdafx.h"
#include <iostream>
using namespace std;
//Multiplication declarations, definitions later in the program
void Adding(int FirstNumber, int SecondNumber);
void Subtracting(int FirstNumber, int SecondNumber);
void Division(int FirstNumber, int SecondNumber);
void Multiplication(int FirstNumber, int SecondNumber);
int main()
{
int FirstNumber, SecondNumber;
SecondNumber = FirstNumber = 0; //Must be valued to something
int ChoiceMenu;
char PlayAgain;
do{ //Start of do-loop
system("CLS"); //Once the loop runs again the previous text will be cleared
cout<<"====================="<<endl;
cout<<"--- Calculator V1 ---"<<endl;
cout<<"====================="<<endl;
//Startup-Menu
cout<<"Menu (1-5)"<<endl;
cout<<"1) Adding"<<endl;
cout<<"2) Subtracting"<<endl;
cout<<"3) Division"<<endl;
cout<<"4) Multiplication"<<endl;
cout<<"5) Quit"<<endl;
cin>>ChoiceMenu;
switch(ChoiceMenu)
{
case 1:
Adding(FirstNumber,SecondNumber);
break;
case 2:
Subtracting(FirstNumber,SecondNumber);
break;
case 3:
Division(FirstNumber,SecondNumber);
break;
case 4:
Multiplication(FirstNumber,SecondNumber);
break;
case 5:
return 0;
}
cout<<"Do you wish to use again (Y/N)?\n";
cin>>PlayAgain;
}while(PlayAgain == 'y' || PlayAgain == 'Y'); //If user inputs "Y" or "y" then loop continues, else it breaks
} //End of do-loop
void Adding(int FirstNumber, int SecondNumber)
{
system("CLS");
cout<<"--------------------"<<endl;
cout<<"----- ADDITION -----"<<endl;
cout<<"--------------------"<<endl<<endl;
cout<<"Enter your first number\n";
cin>>FirstNumber;
cout<<"Enter your second number\n";
cin>>SecondNumber;
cout<<endl;
cout<<"Calculating........."<<endl<<endl;
cout<<"-------------------------------------------------------------------"<<endl;
cout<<FirstNumber<< " + "<< SecondNumber<< " = "<< FirstNumber+SecondNumber<<endl;
cout<<"-------------------------------------------------------------------"<<endl<<endl<<endl;
}
void Subtracting(int FirstNumber, int SecondNumber)
{
system("CLS");
cout<<"--------------------"<<endl;
cout<<"----- SUBTRACTION -----"<<endl;
cout<<"--------------------"<<endl<<endl;
cout<<"Enter your first number\n";
cin>>FirstNumber;
cout<<"Enter your second number\n";
cin>>SecondNumber;
cout<<endl;
cout<<"Calculating........."<<endl<<endl;
cout<<"-------------------------------------------------------------------"<<endl;
cout<<FirstNumber<< " - "<< SecondNumber<< " = "<< FirstNumber-SecondNumber<<endl;
cout<<"-------------------------------------------------------------------"<<endl<<endl<<endl;
}
void Division(int FirstNumber, int SecondNumber)
{
system("CLS");
cout<<"--------------------"<<endl;
cout<<"----- DIVISION -----"<<endl;
cout<<"--------------------"<<endl<<endl;
cout<<"Enter your first number\n";
cin>>FirstNumber;
cout<<"Enter your second number\n";
cin>>SecondNumber;
cout<<endl;
cout<<"Calculating........."<<endl<<endl;
cout<<"-------------------------------------------------------------------"<<endl;
cout<<FirstNumber<< " / "<< SecondNumber<< " = "<< FirstNumber/SecondNumber<<endl;
cout<<"-------------------------------------------------------------------"<<endl<<endl<<endl;
}
void Multiplication(int FirstNumber, int SecondNumber)
{
system("CLS");
cout<<"--------------------------"<<endl;
cout<<"----- MULTIPLICATION -----"<<endl;
cout<<"--------------------------"<<endl<<endl;
cout<<"Enter your first number\n";
cin>>FirstNumber;
cout<<"Enter your second number\n";
cin>>SecondNumber;
cout<<endl;
cout<<"Calculating........."<<endl<<endl;
cout<<"-------------------------------------------------------------------"<<endl;
cout<<FirstNumber<< " * "<< SecondNumber<< " = "<< FirstNumber*SecondNumber<<endl;
cout<<"-------------------------------------------------------------------"<<endl<<endl<<endl;
}
__________________
Vouch(s): -
Quote:
Originally Posted by Pker7
Big Vouch for `Sp3ke Traded my 115 for his Iniate pure he went first nice smooth trade.
|
"All men make mistakes, but it's only the wise who profit from them"
Last edited by `Sp3ke : 12-01-2009 at 07:25 PM.
|

11-30-2009, 11:45 PM
|
|
Active Member
|
|
Join Date: Nov 2009
Posts: 100
|
|
Re: After 2 days of C++
This Has An Error With Directory
|

12-01-2009, 07:25 PM
|
|
Member
|
|
Join Date: Aug 2007
Posts: 80
|
|
Re: After 2 days of C++
Quote:
Originally Posted by Goomba
This Has An Error With Directory
|
What compiler are you using?
__________________
Vouch(s): -
Quote:
Originally Posted by Pker7
Big Vouch for `Sp3ke Traded my 115 for his Iniate pure he went first nice smooth trade.
|
"All men make mistakes, but it's only the wise who profit from them"
|

12-04-2009, 04:05 PM
|
|
Active Member
BANNED
|
|
Join Date: Aug 2009
Location: New York
Posts: 149
|
|
Re: After 2 days of C++
Yeah...C++ is to confusing for me. I'll stick with my c# Lol.
|

12-08-2009, 04:52 AM
|
|
Iloveroy
BANNED
|
|
Join Date: Nov 2008
Location: BC, Canada
Posts: 2,343
|
|
Re: After 2 days of C++
Good work with the switch 
Last edited by tofurocks : 12-08-2009 at 04:52 AM.
|

12-09-2009, 11:59 PM
|
|
Apprentice
|
|
Join Date: Nov 2009
Posts: 629
|
|
Re: After 2 days of C++
Yea Calculator is very fun to make xD
Good Job on it 
|

12-10-2009, 03:55 AM
|
|
Active Member
|
|
Join Date: Nov 2009
Posts: 100
|
|
Re: After 2 days of C++
Quote:
Originally Posted by `Sp3ke
What compiler are you using?
|
Dev C++
|

12-10-2009, 10:00 AM
|
|
Newcomer
|
|
Join Date: Dec 2009
Posts: 5
|
|
Re: After 2 days of C++
Your an idiot, l2 program.
|

12-10-2009, 03:44 PM
|
|
Active Member
|
|
Join Date: Nov 2009
Posts: 100
|
|
Re: After 2 days of C++
Quote:
Originally Posted by Axed99
Your an idiot, l2 program.
|
What!?
|

12-11-2009, 10:34 PM
|
|
Newcomer
|
|
Join Date: Jul 2007
Posts: 10
|
|
Re: After 2 days of C++
Quote:
Originally Posted by Axed99
Your an idiot, l2 program.
|
You're a troll, learn to be a decent human being.
|

12-12-2009, 12:13 AM
|
|
Member
|
|
Join Date: Dec 2008
Posts: 91
|
|
Re: After 2 days of C++
to be brutally honest this thread only attracts retards because the OP is itself retarded.
regardless, have you never heard of function pointers and arrays?
|

04-14-2010, 04:07 AM
|
|
Forum Addict
|
|
Join Date: Apr 2009
Posts: 264
|
|
Re: After 2 days of C++
nice job = ) , i took Intro to C++ then i learned JaVa and now i mostly use java but C++ is fun too.
|

04-15-2010, 11:06 PM
|
 |
Active Member
|
|
Join Date: Jan 2010
Posts: 229
|
|
Re: After 2 days of C++
Quote:
Originally Posted by super_
to be brutally honest this thread only attracts retards because the OP is itself retarded.
regardless, have you never heard of function pointers and arrays?
|
he said its been 2 days -.- You wouldn't learn that in the first 2 days of C++ programming. Nice job in programming though.
|

04-17-2010, 05:13 AM
|
|
Forum Addict
|
|
Join Date: Feb 2007
Posts: 306
|
|
Re: After 2 days of C++
Decent work for 2 days...when I first started I focused on actual computing rather than time-consuming decorations with cout...lol. Oh, and you don't need all those cout's, as one cout for each block of text will suffice.
Anyways, I think you're trying to do too much too fast. You probably want to focus on if's then while's/do-while's then for's. Making that calculator makes use of a switch (which is an if-else) and a do-while, but I don't think you quite understand them yet. Some great ways that I learned about for's and if's was by sorting numbers (either a set number or any amount), testing for prime numbers, or printing out tables (try a multiplication table).
Nice job, but I think you're trying to go too fast...you should probably do some problems with if's before you even get to loops...
Last edited by aznguy94 : 04-17-2010 at 05:14 AM.
|

04-17-2010, 04:53 PM
|
|
Guru
|
|
Join Date: Mar 2009
Location: Efnet
Posts: 1,061
|
|
Re: After 2 days of C++
Good job for 2 days, but I'd like to tell you this: never, ever, ever use system calls.
|

04-22-2010, 02:35 PM
|
|
Member
BANNED
|
|
Join Date: Apr 2010
Posts: 91
|
|
Re: After 2 days of C++
Nice for 2 days
may i ask who taught you?
|
 |
|