Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
After 2 days of C++
Closed Thread
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-30-2009, 06:08 PM
Member
 
Join Date: Aug 2007
Posts: 80
Default 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 View Post
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.
  #2  
Old 11-30-2009, 11:45 PM
Active Member
 
Join Date: Nov 2009
Posts: 100
Default Re: After 2 days of C++

This Has An Error With Directory
  #3  
Old 12-01-2009, 07:25 PM
Member
 
Join Date: Aug 2007
Posts: 80
Default Re: After 2 days of C++

Quote:
Originally Posted by Goomba View Post
This Has An Error With Directory
What compiler are you using?
__________________

Vouch(s): -

Quote:
Originally Posted by Pker7 View Post
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"

  #4  
Old 12-04-2009, 04:05 PM
Active Member

BANNED
 
Join Date: Aug 2009
Location: New York
Posts: 149
Send a message via MSN to Molotov
Default Re: After 2 days of C++

Yeah...C++ is to confusing for me. I'll stick with my c# Lol.
  #5  
Old 12-08-2009, 04:52 AM
Iloveroy
BANNED
 
Join Date: Nov 2008
Location: BC, Canada
Posts: 2,343
Default Re: After 2 days of C++

Good work with the switch

Last edited by tofurocks : 12-08-2009 at 04:52 AM.
  #6  
Old 12-09-2009, 11:59 PM
Apprentice
 
Join Date: Nov 2009
Posts: 629
Default Re: After 2 days of C++

Yea Calculator is very fun to make xD
Good Job on it
  #7  
Old 12-10-2009, 03:55 AM
Active Member
 
Join Date: Nov 2009
Posts: 100
Default Re: After 2 days of C++

Quote:
Originally Posted by `Sp3ke View Post
What compiler are you using?
Dev C++
  #8  
Old 12-10-2009, 10:00 AM
Newcomer
 
Join Date: Dec 2009
Posts: 5
Default Re: After 2 days of C++

Your an idiot, l2 program.
  #9  
Old 12-10-2009, 03:44 PM
Active Member
 
Join Date: Nov 2009
Posts: 100
Exclamation Re: After 2 days of C++

Quote:
Originally Posted by Axed99 View Post
Your an idiot, l2 program.
What!?
  #10  
Old 12-11-2009, 10:34 PM
Newcomer
 
Join Date: Jul 2007
Posts: 10
Default Re: After 2 days of C++

Quote:
Originally Posted by Axed99 View Post
Your an idiot, l2 program.
You're a troll, learn to be a decent human being.
  #11  
Old 12-12-2009, 12:13 AM
Member
 
Join Date: Dec 2008
Posts: 91
Default 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?
  #12  
Old 04-14-2010, 04:07 AM
Forum Addict
 
Join Date: Apr 2009
Posts: 264
Default 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.
  #13  
Old 04-15-2010, 11:06 PM
imtoolazy's Avatar
Active Member
 
Join Date: Jan 2010
Posts: 229
Send a message via MSN to imtoolazy
Default Re: After 2 days of C++

Quote:
Originally Posted by super_ View Post
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.
__________________

chargedback by:damageplan ([email protected]),GF Deborah Dunay
[url=http://sythe.org/showthread.php?t=821487]chargedback by:iProPker ([email protected]),GF FAGGOT
  #14  
Old 04-17-2010, 05:13 AM
Forum Addict
 
Join Date: Feb 2007
Posts: 306
Default 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.
  #15  
Old 04-17-2010, 04:53 PM
Guru
 
Join Date: Mar 2009
Location: Efnet
Posts: 1,061
Default 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.
  #16  
Old 04-22-2010, 02:35 PM
Member
BANNED
 
Join Date: Apr 2010
Posts: 91
Default Re: After 2 days of C++

Nice for 2 days
may i ask who taught you?
Closed Thread



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 05:44 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1