CoolGamer48 65 Posting Pro in Training

Ok well i aint mean do it i guess ma question would be how would i read a file with this info into a linked list

So you want to know about file streames and linked lists. For reading files: ifstream, and for linked lists, see the link two posts above.

CoolGamer48 65 Posting Pro in Training

No one's going to do this for you. If you have a specific question - ask that. To start off, do you know what a linked list is?

CoolGamer48 65 Posting Pro in Training

I'm assuming it took many trained, experienced, professionals working an absolute minimum of 8 hours a day a couple of years to write the Unreal engine (again, an assumption). I'm not sure how much experience you have, but I don't think you're going to have too much luck witting an engine similar in quality to the Unreal engine.

Though, if by "similar to Unreal", you were merely giving an example of another engine of unrelated magnitude, then you would have luck with that (again, depending on your experience level, but definitely more possible).

However, the only development tool for the 360 that is available to the public is XNA, and I'm unsure as to how well you could write an engine with XNA. And I don't think there are any development kits for the PS3 available to the public. But for the PC you can use DirectX or OpenGL.

CoolGamer48 65 Posting Pro in Training

And that won't happen with the #ifndef "protection", if I'm right.

I'm not so sure: if file A #includes file B, and file B #includes file A, and file A is #included by the main project first, then this will happen:

file A #includes file B
file B #includes file A (the code within the file will not be looked at, but the #ifndef will still need to be processed)
file A #includes file B
file B #includes file A
and so on...

the chain will never end (if I am correct, which I admit I may not be)

Also, (again not 100% sure), Breeture.h doesn't need to know anything about the class World (it needs to know it exists, but nothing else). so I think you can replace #include "World.h" with class World; (like a prototype).

Once again - I'm not too sure on any of this, but I think this should solve the problem.

CoolGamer48 65 Posting Pro in Training

Er... I'm not exactly sure what you're asking, but it sounds like you may be searching for the break command. Having break; anywhere in a loop will end the current iteration and end the loop. If that's not it, then continue; will end the current iteration, but instead of breaking out of the loop, control will return to the top of the loop, and another iteration will be executed (assuming the conditional is still true).

CoolGamer48 65 Posting Pro in Training

First, some stuff on cleaning up your code. Skip to the bottom for the solution I think you're looking for.

second = (number-dig1) / 100;
dig2 = second % 10;

looks like it should be just dig2 = (number-dig1*1000) / 100; So if your number is 3255, digit one would be 3, then 3255-3*1000 = 255, and then that divided by 100 equals 2 (with int truncation).

Then, for the third number, you have

third = number / 10;
dig3 = third % 10;

The variables second, third, and fourth seem unneccesary to me. Just do dig3 = ((number-dig1*1000)-dig2*100)/10 . That way, with the 3255 example, dig1 = 3, number-dig1*1000 = 255, and that minus dig2*100 = 55. 55/10 is 5, your third digit.

And a simmilar thing with dig4: dig4 = (((number-dig1*1000)-dig2*100)-dig3*10) .

The code you have may have worked too, but this seems less messy. There may be better ways still to do this, but w/e.

The reason that your program is only doing it once, is that you have return 0; at the end of your loop (in the loop, not after it). This means that after one iteration of the loop the program will terminate. Move return 0; to outside the loop, but still inside the main() function.

CoolGamer48 65 Posting Pro in Training

First off, for(;conditional;) is the same as while(conditional) . So you can fix that. Also, initial_loan_amount is being declared but not initialized (i.e., its filled with nonsense). Fix that.

CoolGamer48 65 Posting Pro in Training

You could get the whole thing into a string or an array and then convert it into Int.

Yes, that approach would be effective. However the OP said something about using modulus to find the answer, which you wouldn't need if you took the data in as a string.

So it would be good if the OP could post the exact promt.

CoolGamer48 65 Posting Pro in Training

No it doesn't. He had the basic code for it somewhere above. You take in the number as one value using cin, and you yourself take it apart and figure out the different digits. If the number is four digits long, we can obtain the thousands place with floor(number/1000), the hundreds place with floor((number%1000)/100), the tens with floor(((number%1000)%100)/10), and the ones with floor(((number%1000)%100)%10).

CoolGamer48 65 Posting Pro in Training

I believe every four digit number had to be taken in at once, not each digit separately (otherwise your approach works). But I'm not sure exactly, so I'm waiting for him to try and clarify exactly what the program needs to do.

CoolGamer48 65 Posting Pro in Training

Do you have the exact prompt with you? Could you post it, because I doubt that all six of the inputs would be put in at once without any breaks. I think they might mean that the digits within each of the six numbers need to be taken it at once, but not all the numbers together.

CoolGamer48 65 Posting Pro in Training

Er... at first you said

the given integers will all consist of four digits

. But you just mentioned six digits. And then you gave 325510671393289211112020, which is a 24 digit number, and then broke it up into six sections of four digits, treating each one like a "digit". Then you performed the digit operations that you mentioned (first*3 + second*third - fourth) on the first four of those "digits", and just ignored the last two. What exactly is the program supposed to do? Give an example of input, output, and an explanation, because what you just said contradicts what you said originally.

CoolGamer48 65 Posting Pro in Training

There is no need to use floor() as int truncates any decimal place as it is.

Is that method of truncation considered "safe"? I thought it wasn't a good idea to let C++ take care of the truncation for you when you pass a non-integral number to an int.

CoolGamer48 65 Posting Pro in Training

Well i am sorry .. MAde a bad comment on that one. I respond with DEEP apologies.

And edit my post as well

No need to apologize - just pointing it out. Everybody makes mistakes.

CoolGamer48 65 Posting Pro in Training

As for the floor() thing, I think you are getting floor() confused with a rounding function. floor() always rounds down, so floor(3.812) would be 3, not 4. conversely, ceil() always rounds up. so ceil(3.224) would be 4, not 3.

if you used abs() to truncate the non-integral part of the number, you would just be doing the same thing that he's currently doing, only doing indirectly through the abs() function, and not on your own.

CoolGamer48 65 Posting Pro in Training

You might want to repost your program (using code tags) to see if it really was fixed.

Also, you may want to change something like

first = number/1000;

to

first = floor(number/1000);

floor() is declared in math.h (so add #include<cmath> or #include<math.h> to the top of your source). i think it would be better than simply relying on the integer round down, but it won't really change your program's results.

CoolGamer48 65 Posting Pro in Training

Um, ok, first of all, what exactly is z for?

Second - look at this:

void initialize (int& x,int& y,char& z)
{
int num;
cout<<"Enter Integer"<<endl;
cin>>num;
}

This function takes in three parameters but does nothing with them. Try to fix that... I'm not entirely sure what you're trying to do here anyway

CoolGamer48 65 Posting Pro in Training

The amount went to 500. I need it to be 460 though. I feel we are almost there though.

Sorry - it's

amount = (40*rate) + (( hours - 40 ) * ( rate * perhour));

That's should do it.

And just fyi, on line 34 you have

else if (hours >= 40)

. This won't affect your program at all, but it should be:

else if (hours > 40)

, since if amount == 40, you would want the first if block to handle the code

CoolGamer48 65 Posting Pro in Training

Allright, so as I understand it: the fact that perhour = 1.5 means that for any hours worked over 40 hours, you receive 1.5 times your regular rate (perhour seems like a weird name for that). If that's the case, then this line (35):

amount = (( hours - 40 ) * ( rate * perhour));

is only calculating the EXTRA money earned. Not the total money earned. To get the total, you would replace the line above with:

amount = (hours*rate) + (( hours - 40 ) * ( rate * perhour));
CoolGamer48 65 Posting Pro in Training

If you didn't get it from the above post:

on line 14, you declare amount as a double, but don't initialize it to anything. then, in the getHoursRate() function, you declare a SECOND double called amount, which will go out of scope as soon as the function ends. you're saving the value you want for amount in getHoursRate()'s version of amount, and then, on line 16, your using main()'s version of amount, which is still uninitialized, and that's why you get some really weird number for your output.

getHoursRate() either needs to take a third reference to amount, or it needs to return the amount, which you would then store in main()'s version of amount.

Edit: you've got a simmilar situation with initialize. you've got three parameters, but you're not doing anything with them

CoolGamer48 65 Posting Pro in Training

I really like MS Visual C++ Express Edition's code editor. You can easily check #defines, function parameter options, and other things just my moving your mouse over something. You also get a list of member functions when you type the . or -> after an object of a class (you might not know what most or any of that means yet - I find it helpful when using DirectX, where you have lots of functions and classes that you haven't written yourself and don't know the inner workings of). I don't particularly mind the rest of the compiler, but I'm sure other people do, if for no reason other than it's Microsoft. Another nice compiler is Dev-C++, or wxDev-C++.

CoolGamer48 65 Posting Pro in Training

For my experience (which I'll admit is relatively limited), books are often a better learning tool than online tutorials for complex programming languages like C++. If you've got the cash, I'd buy a book. I learned C++ from C++ for Dummies by Stephen Randy Davis. I really love Davis's writing. cplusplus.com and other sites like it are good for quick lookups of functions or syntax, but if you want to learn the language from the ground up, go with a book. :)