chococrack 74 Junior Poster

Did you declare a pointer without allocating memory?

type_of_var *p;
p = new type_of_var; // allocate memory

We're really completely in the dark without any code.

chococrack 74 Junior Poster
int main()
{
	int AccountNumber, loop, loopEnd;
	double InputBalance, MinimumBlanace, FinalBalance, CheckTopLimit;
	char AccountType;
	bool validAccount = false;

	ofstream fout;
	ifstream fin;

	fin.open("bankdata.nf0"); 
	fout.open("bankdataout.nf0");


	while (validAccount == false) 
	{
		cout << "Please enter the amount of accounts" 
                       << "that will be updated for this month." << endl; 
		cin >> loopEnd;
		for(int i=1; i<=loopEnd; i++)
		{	
			fin >> AccountNumber >> AccountType 
                            >> MinimumBlanace >> InputBalance;
			switch(AccountType) 
			{
			case 's':
			case 'S':
				{
					if (InputBalance < MinimumBlanace) 
					InputBalance = InputBalance
                                              - SAVINGS_FEE;
					else
					InputBalance = (SAVING_INTEREST
                                             * InputBalance) 
                                             + InputBalance;
					FinalBalance = InputBalance;
					validAccount = true;
					break;
				}
			case 'c':
			case 'C':
				{
					if (InputBalance >= MinimumBlanace)
					{
						CheckTopLimit = CHECKING_TOP_LIMIT 
                                                      + MinimumBlanace;
						if (InputBalance <= CheckTopLimit)
						InputBalance = (InputBalance 
                                                      * CHECK_LOW_INTEREST) 
                                                      + InputBalance; 			
						else 
						InputBalance = (InputBalance 
                                                      * CHECK_HIGH_INTEREST)
                                                      + InputBalance;
					}
					else
					InputBalance = InputBalance - CHECK_FEE;
					FinalBalance = InputBalance;
					validAccount = true;
					break;
				}
			default:
				{
					validAccount = false;
					break;
				}

			} 





			fout << fixed << showpoint << setprecision(2);
			fout << setw(15) << "ACCOUNT NUMBER" 
                              << setw(14) << "ACCOUNT TYPE" 
                              << setw(22) << "NEW CURRENT BALANCE" 
                              << endl;
			fout << setw(15) << AccountNumber 
                              << setw(14) << AccountType 
                              << setw(22) << FinalBalance 
                              << endl;
			fout << endl  << endl << endl << endl;

			cout << fixed << showpoint 
                              << setprecision(2);
			cout << setw(15) << "ACCOUNT NUMBER" 
                               << setw(14) << "ACCOUNT TYPE"
                               << setw(22) << "NEW CURRENT BALANCE" 
                               << endl;
			cout << setw(15) << AccountNumber 
                               << setw(14) << AccountType
                               << setw(22) << FinalBalance 
                               << endl;
			cout << endl << endl …
chococrack 74 Junior Poster

You didn't seed the random number generator, so you're getting the same result everytime.

srand(time(0));  // Initialize random number generator.

Oh and on a side note, I love your code. It's very easy to follow.

chococrack 74 Junior Poster

Well, what I ended up doing is making a function to draw the whole setting (drawSetting) - the stick person, the box, the platform, etc etc.

The cleardevice() function clears the whole screen (no setting, no circle). Then the setting is redrawn, and the circle is redrawn in the new position (pos_x, pos_y)

Basically this is the only way I could figure out how to do it. It would look a lot smoother if we could erase or delete the circle we've drawn, but I do not know a way to do that other than clearing the whole canvas.

Is it clearer now?

chococrack 74 Junior Poster

You can solve this problem in 7 or less lines of code.

chococrack 74 Junior Poster

Read the binary to decimal routine he gave you thoroughly...

chococrack 74 Junior Poster
scout *p;
p = new scout; //allocate the memory for a new scout struct
chococrack 74 Junior Poster
#include <iostream>
#include <conio.h>
#include <graphics.h>

// using namespace std;


void drawSetting(); // Function to redraw everything

int main(void)
{

double pos_x,i_pos_x,pos_y,i_pos_y,vel_x,vel_y;
double time,gravity ; //t=time,g=gravity
int x_position,y_position;

initwindow(640,480);




//ball
//setcolor(RED);
//circle(90,250,10);
//setfillstyle(1,4);
//floodfill(90,250,4);




pos_x=90;
i_pos_x=90;
pos_y=250;
i_pos_y=250;
vel_x=60;
vel_y=60;
gravity=9.81;
time=6.2;

moveto((int)pos_x,(int)pos_y);
for(pos_x=i_pos_x;pos_y>0;pos_x++)
{
    time=(pos_x-i_pos_x)/vel_x;
    pos_y=i_pos_y-(vel_y*time)+(9.81*time*time);
    //lineto((int)pos_x,(int)pos_y);
    cleardevice();
    drawSetting();
    setcolor(RED);
    circle(pos_x,pos_y,10);
    setfillstyle(1,4);
    floodfill(pos_x,pos_y,4);
    delay(7);
}



getch ();
closegraph();
return 0;
}

void drawSetting()
{
    //stick person
    setcolor(CYAN);
    circle(50,200,30);
    setfillstyle(1,3);
    floodfill(50,200,3);

    setcolor(CYAN);
    line(50,230,50,300);//badan
    line(20,250,80,250);//tangan
    line(50,300,90,340);//kaki kanan
    line(50,300,10,340);//kaki kiri




    //stand
    setcolor(3);
    line(0,340,110,340);//2
    line(110,340,110,450);//3
    line(0,450,110,450);//4
    line(0,340,0,450);//1
    setfillstyle(1,3);
    floodfill(100,440,3);


    line(0,450,640,450);//platform

    //box
    line(400,380,400,450);//1
    line(400,450,500,450);//2
    line(500,380,500,450);//3
}

This works somewhat... I do NOT like the way it looks. :<

chococrack 74 Junior Poster
for(pos_x=i_pos_x;pos_y>0;pos_x++)
{
    time=(pos_x-i_pos_x)/vel_x;
    pos_y=i_pos_y-(vel_y*time)+(9.81*time*time);
    // lineto((int)pos_x,(int)pos_y);
    circle(pos_x,pos_y,10);
    setfillstyle(1,4);
    floodfill(90,250,4);
    delay(1);
}

Is where I'm at now. All we need is something to destroy the previous circle and we're golden.

chococrack 74 Junior Poster

Alright so I got the line to go further with this here:

for(pos_x=i_pos_x;pos_x<555;pos_x++)

my suggestion is something along the line of instead of having pos_x < XXX have it say something like pos_y > 0 (If its the ground you're trying to strike)


ROFL.. I just re-read your post. I'm not even looking at it right. I'll try something with the ball now

My fault

chococrack 74 Junior Poster

int main()

to begin... more to follow...

Does your compiler fuss at you for not having header files or anything?


Ahh I see what the problem is.. the arch is stopping or getting too slow. Let me see if I can track it down.

and the int main(void) still works fine anyhow

chococrack 74 Junior Poster

If it's the instructions you're having trouble with then allow me to assist you:

You have to develop a decimal to binary function.

The decimal number that will go into your function is the one which will be produced from using the given "binary to decimal" function.

You have to add a second test to function main (the driver) to show that your function returns the correct binary number.

chococrack 74 Junior Poster
[B]void[/B] BST<KeyType, DataType>::traverse(TraverseType traverseType, void (*visit)(DataType))

Also, what the above comment suggests, your function is declared as a void (which means it doesn't return anything) and you're attempting to stuff the information returned (nothing) into the variable result.

Eliminate the result variable, or set traverse to a bool and have it return a true if a traversal takes place, false otherwise.

chococrack 74 Junior Poster

whoa

ifstream inData;
    inData.open("Unknown.txt");

Try pulling that out of the for loop

chococrack 74 Junior Poster

1. Implement a stack class in 42 lines or less (including blank lines and braces).

GO!

chococrack 74 Junior Poster

I didn't see the need for it, especially since you already stated what the acceptable inputs were. It's true that you don't want to allow erroneous inputs, but its not a pace-maker application.

chococrack 74 Junior Poster

Nevermind. Damn. Got to it in time.

chococrack 74 Junior Poster

1! = 1
2! = 1 x 2 = 2
3! = 1 x 2 x 3 = 2! x 3 = 6
N! = 1 x 2 x 3 x .... (N-2) x (N-1) x N = (N-1)! x N

Could this help?

A guess:

int theFact = 1;
for(int i=N; i>0; i--)
{
     theFact *= i;
}

return theFact;
chococrack 74 Junior Poster

numbers[insertItem-1] = insertItem;

Does this mean if you insert, oh i dont know, "6432", it goes into numbers[6431]???

If it does I'd look at it again, because I don't think that's what you WANT it to do

chococrack 74 Junior Poster

>using namespace std; // out of place
Actually, that's a better place than your proposed solution.

Neat stuff thanks for the feedback. I do appreciate lots of your posts. I learn a lot of neat things. Had no idea it was even legal to use a directive on a block scope.

chococrack 74 Junior Poster

The answer is most assuredly forty-two.

chococrack 74 Junior Poster
Data superStruct;
superStruct.name = thatLastNameIRead;
superStruct.address = thatAddressIRead;
int mySuperKey = thatKeyIRead;

myBST.insert(thatKeyIRead, superStruct);

What is the question?

You don't need to do anything to the other two inputs, they're strings already, which is what the struct's values are.

Parsing refers to breaking something into parts, in general. Hope this helps.

chococrack 74 Junior Poster
#include <iostream>

int main()
{
[B]	using namespace std;[/B]  // out of place
	int exercise[5], i;

	[B]cin >> exercise[0];[/B]  // is only entering one value 

	for (i = 0; i < 5; i++)
	{
		cout << exercise[i] << endl;
	}

	return 0;

}
#include <iostream>

[B][I]using namespace std;[/I][/B]

int main()
{
    int exercise[5];
    for(int i=0; i<5; i++)   // C++ arrays start with index 0, so its 0, 1, 2, 3, 4
    {
        cin >> exercise[i];   // index[0] gets 1, [1] gets 2, ...
        cout << exercise[i]; // as you input, 12345, it will also output
    }

    for(int i=0; i<5; i++)
    {
        cout << element[i] << endl; // endl is endline (or a new line)
    }

    return 0;
}
chococrack 74 Junior Poster

dis:

for(int i=0; i<5; i++)
{
    for(int j=0; j<5; i++)
        cout << "*"
    cout << endl;
}
chococrack 74 Junior Poster

Yep you only need it once for the entire program. Then just call rand() % 52 wherever you need it.

If you're going to be doing a bunch of random numbers at a time, its a good idea to have it wait a bit before generating the next number.

chococrack 74 Junior Poster

That code yields:

3, 7 , 11, 15, 19, 23, 27, 31 ...

I think you're on the right track though.

I'm trying to figure this one out too.

chococrack 74 Junior Poster
chococrack 74 Junior Poster

The link I posted should solve your problem.

chococrack 74 Junior Poster
template<class T> 
class snake; 

template<class T>
struct node
{
    T data;
    node *next;
};


template<class T>
class  snake 
{

// . . .
private:
     node *start_ptr;

// . . .

};
chococrack 74 Junior Poster

http://www.cplusplus.com/reference/clibrary/cstring/strcmp.html

strcmp:

Compares the C string str1 to the C string str2.

This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminanting null-character is reached.

chococrack 74 Junior Poster
chococrack 74 Junior Poster

If you've made your network private, you've got your network key plugged into your laptop I hope :X

chococrack 74 Junior Poster

Yep. And likely if you post the actual code you're working on, I bet the indexed post will pop up on google too.

chococrack 74 Junior Poster

62: ptr->item;
what about it?


89. while(ptr->next !=NULL)
figure out why in ptr->next never becomes null

I'm betting on the problem being in your insert function.

chococrack 74 Junior Poster

this is certainly a bugger. I ended up having to re-route what I was trying to accomplish. I do appreciate the help.

chococrack 74 Junior Poster
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int even = 0, odd = 0, dig, num;

	cout << "Please enter a list of numbers (-7777 to terminate)" << endl;
	cin >> num;

	while (num != -7777)  // off the wall check value
	{
		
		// dig = num % 10;
		// num = num / 10;           <--- what are these for?


		
		if(dig % 2 == 0)       // if the number is even
			even += num; // add it to the previous even sum						
		else
			odd += num;   // otherwise add it to the odd sum

		cout << "Enter next number: ";
		cin >> num;
	}

	cout << "The sum of the even integers is: " << even << endl;
	cout << "The sum of the odd integers is: " << odd << endl;

	return 0;
}
chococrack 74 Junior Poster

Follow this link and read up on ctime for MFC applications. Seems you just need to set up a time interval of some sort, (ie if the user twiddles thumbs for 30 seconds, just continue)

http://www.cplusplus.com/reference/clibrary/ctime/

Also for developing small projects at home I find Bloodshed Dev++ to be very affordable and efficient.

http://www.bloodshed.net/devcpp.html

chococrack 74 Junior Poster

Item *tempItem = items;
cout << *tempItem;

????

chococrack 74 Junior Poster

if (!Continue())

is the same as saying

if (Continue() != true)

is the same as saying

if (not Y/y)

chococrack 74 Junior Poster

Look at line 13

stop = num;

Now ask yourself, "self, whats stop?"
"a character."
"self, whats num?"
"an integer."

Whats probably going down is that the the char (stop) is being assigned an integer, which in effect is tossing your loop off.

Are you only interested in positive integers? Because then you could ask for a negative value to terminate that list of integers.

while(num != -1)
chococrack 74 Junior Poster
mean3(value1, value2, value3);

Whats happening here is that your returned value has nothing to come back to. In other words, the function is executing but then the returned value (mean) is flying off into fairy world.

Do what Denniz said, just adding a "cout<<" to the front, or you could also just write:

mean = meanOf3(value1, value2, value3);

Both work fine

chococrack 74 Junior Poster

Nah, &this is illegal, compiler fusses at me :D Time for a new approach ::cracks fingers::

chococrack 74 Junior Poster

Since I need to change the actual object itself, I would need to do something along the lines of &this

Unsure of if its legal or not, going to try it now. Thanks for the quick replies.

chococrack 74 Junior Poster
void myClass<temp_Type>::myFunction(myClass<temp_Type>* &firstClass, myClass<temp_Type>* secondClass)
{
     
}

[call]

myFunction(*this, &secondClass);

I think I am fundamentally challenged on the "this" qualifier. I want to pass a pointer to the current object(ie the object I am calling the function from), but am stuck trying to pass the "this". Are there any other methods to go about something such as this?

chococrack 74 Junior Poster
#include <motivation.h>
#include <drive.h>
#include <dignity.h>

using namespace omg;

int main()
{
    string whatAreYouThinking = "foppishness";
    int numOfPeopleWhoWillHelpYou = 0;
    string typicalResponseToThis = "rofl";
    big_Surprise(whatAreYouThinking, numOfPeopleWhoWilHelpYou, typicalResponseToThis) = goDoYourOWNhomework;
return 0;
}
Ancient Dragon commented: Genious :) +36
twomers commented: It's <cdignity> strictly for C++, but I approve of this level of cynicism with only 5 posts. Good work! +6
bhoot_jb commented: good program :D +1
chococrack 74 Junior Poster

Really? Is there another American public I'm not aware of?
:)

rofl. The other other America!

chococrack 74 Junior Poster

Everyone is perfectly safe, theres even webcams to watch:

http://www.cyriak.co.uk/lhc/lhc-webcams.html


;)

chococrack 74 Junior Poster

She spoke more to idiot America, with a cheerful, emotionally charged, do-gooder attitude that people love. And its true that America votes for the best speakers, because psychologically we're stuck in a deferential society based on emotional response from debates and speeches.

Like one of the previous posters said, Biden was factual and boring. Basically, all he came back with was "let me answer that... blah blah blah buhh buhh buhh."

Sarah won this debate.

chococrack 74 Junior Poster

Hi folks, my name is Blake. I live in Southern Louisiana and am currently a second year computer science student at the local university. I am flabbergasted from working on this current project and happened to find this website on a much needed break.

Narue's signature is what caught my eye: I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.

So true.

Anyway hi.

<3