Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 05-25-2004, 03:02 PM
kugrug
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default Junior Developer Code

#include <iostream>
int main ()
{
int a, b ,c;
std::cout << "Enter 2 Numbers to Add
";
cin >> a;
cin >> b;
c=(a+b);
std::cout << "Sum is = " << c;
int x;
std::cin >> x;
return 0;
}


also this, but i dont know how to make it keep going, like change days every 24 hours, but hey you can change it every morning if you like


#include <iostream>
int main ()
{
enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };
Days today;
today = Wednesday;
if (today == Sunday || today == Saturday)
std::cout << " Woot Weekends!";
else
std::cout << "Damn School. Today is" << today;
int x;
std::cin >> x;
return 0;
}


Now im only 13 so please be polite and not critisize(no idea how to spell) But im working on C++ and i wanna help cuz me be bored
Reply With Quote
  #2  
Old 05-25-2004, 03:39 PM
mangoo
Items Master
 
Join Date: Apr 2003
Posts: 293
Default

I think what they were looking for are cope snippets of bug fixes for the emulator. Not your high school class tutorials .
__________________
Reply With Quote
  #3  
Old 05-25-2004, 04:08 PM
kugrug
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default

im not in high school yet
Reply With Quote
  #4  
Old 05-25-2004, 04:29 PM
mangoo
Items Master
 
Join Date: Apr 2003
Posts: 293
Default

Ya I didn't pay much attention to the age 13 action there. Anyhow in HS CS the above is what you do everyday / play games.
__________________
Reply With Quote
  #5  
Old 05-25-2004, 10:14 PM
Scorpious2k's Avatar
Scorpious2k
Demi-God
 
Join Date: Mar 2003
Location: USA
Posts: 1,067
Default

Keep working on it and don't give up. You'll get there. And you'll be surprised how fast you learn if you keep at it.

There are a lot of tutorial type sites on the internet. Visit them and try them out. Download the source for the emulator (and keep it up to date). It isn't a good example of "ideal" code, but its a great example of real world code that gets maintained and changed constantly. Check out changes other people post. Look at the code and try to figure it out. Be curious.

Don't get discouraged if you don't get it right away. I like to describe it as like jumping into the deep end of a pool... you are in over your head. Thinking you will never make it up to the air... then, finally you take that deep breath and go "wow! I'm going to do THAT again"
__________________
Maybe I should try making one of these servers...
Reply With Quote
  #6  
Old 05-25-2004, 11:53 PM
kugrug
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default

i just downloaded the source for 5.6 what should i look at, i took a look at guilds and couldnt understand what it was talking about
Reply With Quote
  #7  
Old 05-26-2004, 12:03 AM
kugrug
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default

Does anyone have a c++ calulator source?
Reply With Quote
  #8  
Old 05-26-2004, 02:30 AM
maaltan
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default calculator

a very simple calculator, im just typing it in here so you might have to correct some small compile errors, but the logic should be sound.
That would make a good debugging exercise for the trainees

I tried leaving pointers out of it .. but hell thats what c runs on you have to learn them eventually.

You will have to break out though its infinate

Code:
#include <stdio.h>

int main()
{
 float oprand; 
    float accumulator; 
    char buf=' ';

while (1) 
{ 
   printf("Enter a the first number\n"); 
   scanf("%f", &accumulator); 
   buf = ' ';
while (buf != '=') 
{
   
   printf("Enter +,-,*, /   Or enter = to get result\n");
   scanf("%s", &buf);

   if (buf != '=')
   {
	   printf("Enter next number.\n");
	   scanf("%f", &oprand);
   }

   switch (buf)
   {
        case '+':
               accumulator+=oprand;
			   break;
        case '-':
               accumulator-=oprand;
			   break;
        case '*':
               accumulator*=oprand;
			   break;
        case '/':
               accumulator/=oprand;
			   break;
        case '=':
                printf("Result: %f\n", accumulator);
				break;
        default:
            printf("invalid operator\n"); // have to have it to prevent the program from crashing, you may wish to put debugging info in here
    }

}
}

} // err lost track of braces this might not be needed
well its started out simple .. hope it helps actually it turned out to be c instead of c++ .. eeh it will work in c++ .. replace the printfs and scanfs with cin and cout stream redirections like your use to ..then it be c++
Reply With Quote
  #9  
Old 05-26-2004, 07:04 AM
kugrug
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default hey

thanks for that, i couldnt get the case command to work before
Reply With Quote
  #10  
Old 05-26-2004, 07:52 AM
cofruben
Old-EQEmu Developer
 
Join Date: Oct 2002
Location: Spain
Posts: 323
Default

Code:
#include <stdio.h> 
void Calculator();
int main() 
{
	Calculator();
	return 0;
}
void Calculator(){
	int x=0; //  for the loop
	printf("Starting Calculator...\n");
	float numbertwo; 
    float numberone;
	char action;
	float result=0;

	while(x==0){
		 printf("Enter the first number:   "); 
		 scanf("%f", &numberone);
		 printf("\nEnter +,-,* or / :        "); 
		 scanf("%c", &action); 
		 scanf("%c", &action); 
		 printf("\nEnter the second number:  ");
		 scanf("%f",&numbertwo);

		 switch (action) 
		 { 
				case '+': 
					   result=numberone+numbertwo; 
					break; 
				case '-': 
					   result=numberone-numbertwo; 
					break; 
				case '*': 
					   result=numberone*numbertwo; 
					break; 
				case '/': 
					result=numberone/numbertwo; 
					break; 
				default: 
					printf("invalid operator\n"); // non-valid character.
					x=1;
		}
		printf("                          --------\n");
		printf("                          %f\n\n",result); //  prints the result
	}
}
simple code.
Reply With Quote
  #11  
Old 05-26-2004, 08:55 AM
kugrug
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default

hey i tried make it the way i coud read it so far no errors but when i try to execute it doesnt do anything


#include <stdio.h>
#include <iostream>
int main ()
{
float numberone;
float numbertwo;
char action;
int x=0; // loop
float result=0;
while (x==0){
std::cout << "Enter 1st First Number ";
cin >> numberone;
std::cout << "\nEnter +,-,* or / : ";
cin >> action;
std::cout << "\n Enter Second Number ";
cin >> numbertwo;
switch (action)
{
case '+':
result=numberone+numbertwo;
break;
case '-':
result=numberone-numbertwo;
break;
case '*':
result=numberone*numbertwo;
break;
case '/':
result=numberone/numbertwo;
break;
default:
std::cout << "invalid operator\n"; // non-valid character.
x=1;
}
std::cout << " --------\n";
std::cout << " %f\n\n",result; // prints the result
int b;
std::cin >> b;
return 0;
}
}
Reply With Quote
  #12  
Old 05-26-2004, 09:20 AM
maaltan
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default

hrm .. i think i remember something in the rules about not helping people learn how to code in this forum, maybe a moderator can move this thread to misc or something...


anyway. Im using vc++. i got several compile errors. this is pretty normal. Your code might be fine but vc++ is insane i think .. couple of quick things you might try though

first change your include to :

#include <iostream.h>

and remove the std:: from the stream access commands

so just put:

cin >> blah;

cout << "this is blabhblablabh";

again im rusty when using the iostreams so this might not be correct.

also, i don't think you can use printf formatting keys with the streams. you have to piece together a fully formated string (using sprintf maybe) and pass it to cout. I might be wrong on this .

-------

ok i am editing my post. I just checked out cout

your statement :

cout << " %f\n\n",result; // prints the result

should read:

cout << result << "\n\n"; // prints the result

that makes it work.
Reply With Quote
  #13  
Old 05-26-2004, 10:13 AM
kugrug
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default

Hey same problem but this time it crashes or lags
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 09:46 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3