After 2 days of C++

Discussion in 'Programming General' started by `Sp3ke, Nov 30, 2009.

Thread Status:
Not open for further replies.
After 2 days of C++
  1. Unread #1 - Nov 30, 2009 at 1:08 PM
  2. `Sp3ke
    Joined:
    Aug 2, 2007
    Posts:
    80
    Referrals:
    0
    Sythe Gold:
    0

    `Sp3ke Member

    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;
    }
    
     
  3. Unread #2 - Nov 30, 2009 at 6:45 PM
  4. Goomba
    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0

    Goomba Active Member

    After 2 days of C++

    This Has An Error With Directory
     
  5. Unread #3 - Dec 1, 2009 at 2:25 PM
  6. `Sp3ke
    Joined:
    Aug 2, 2007
    Posts:
    80
    Referrals:
    0
    Sythe Gold:
    0

    `Sp3ke Member

    After 2 days of C++

    What compiler are you using?
     
  7. Unread #4 - Dec 4, 2009 at 11:05 AM
  8. Molotov
    Joined:
    Aug 26, 2009
    Posts:
    149
    Referrals:
    0
    Sythe Gold:
    0

    Molotov Active Member
    Banned

    After 2 days of C++

    Yeah...C++ is to confusing for me. I'll stick with my c# Lol.
     
  9. Unread #5 - Dec 7, 2009 at 11:52 PM
  10. tofurocks
    Joined:
    Nov 8, 2008
    Posts:
    2,344
    Referrals:
    2
    Sythe Gold:
    0

    tofurocks Iloveroy

    After 2 days of C++

    Good work with the switch :)
     
  11. Unread #6 - Dec 9, 2009 at 6:59 PM
  12. Pain Killer
    Joined:
    Nov 16, 2009
    Posts:
    629
    Referrals:
    0
    Sythe Gold:
    0

    Pain Killer Apprentice
    Banned

    After 2 days of C++

    Yea Calculator is very fun to make xD
    Good Job on it :D
     
  13. Unread #7 - Dec 9, 2009 at 10:55 PM
  14. Goomba
    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0

    Goomba Active Member

    After 2 days of C++

    Dev C++
     
  15. Unread #8 - Dec 10, 2009 at 5:00 AM
  16. Axed99
    Joined:
    Dec 10, 2009
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0

    Axed99 Newcomer

    After 2 days of C++

    Your an idiot, l2 program.
     
  17. Unread #9 - Dec 10, 2009 at 10:44 AM
  18. Goomba
    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0

    Goomba Active Member

    After 2 days of C++

    What!?
     
  19. Unread #10 - Dec 11, 2009 at 5:34 PM
  20. madman340
    Joined:
    Jul 6, 2007
    Posts:
    10
    Referrals:
    0
    Sythe Gold:
    0

    madman340 Newcomer

    After 2 days of C++

    You're a troll, learn to be a decent human being.
     
  21. Unread #11 - Dec 11, 2009 at 7:13 PM
  22. super_
    Joined:
    Dec 20, 2008
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0

    super_ Member

    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?
     
  23. Unread #12 - Apr 13, 2010 at 11:07 PM
  24. zbubblez
    Joined:
    Apr 14, 2009
    Posts:
    354
    Referrals:
    0
    Sythe Gold:
    0

    zbubblez Forum Addict

    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.
     
  25. Unread #13 - Apr 15, 2010 at 6:06 PM
  26. imtoolazy
    Joined:
    Jan 5, 2010
    Posts:
    229
    Referrals:
    1
    Sythe Gold:
    0

    imtoolazy Active Member

    After 2 days of C++


    he said its been 2 days -.- You wouldn't learn that in the first 2 days of C++ programming. Nice job in programming though.
     
  27. Unread #14 - Apr 17, 2010 at 12:13 AM
  28. aznguy94
    Joined:
    Feb 11, 2007
    Posts:
    304
    Referrals:
    0
    Sythe Gold:
    0

    aznguy94 Forum Addict

    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...
     
  29. Unread #15 - Apr 17, 2010 at 11:53 AM
  30. PublicityFtF
    Joined:
    Mar 10, 2009
    Posts:
    1,178
    Referrals:
    0
    Sythe Gold:
    0

    PublicityFtF Guru
    Banned

    After 2 days of C++

    Good job for 2 days, but I'd like to tell you this: never, ever, ever use system calls.
     
  31. Unread #16 - Apr 22, 2010 at 9:35 AM
  32. vbpro
    Joined:
    Apr 20, 2010
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0

    vbpro Member
    Banned

    After 2 days of C++

    Nice for 2 days
    may i ask who taught you?
     
< Begin learn java | Each download this file, 0,10 $ >

Users viewing this thread
1 guest
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site