1,426 Posted Topics
Re: What part are you getting hung up on? Do you know how to create a struct? | |
Re: Well a prime number can only be divided by 1 and itself. With that you can write a function that you pass the number to check and return a bool for the resault. To find out if a number is prime you need to use the mod operator on it … | |
Re: Your constructor should look like this Polynomial::Polynomial() { degree = 0; coeffs = NULL; } | |
Re: Ill give you a hint. You will need to use 2 for loops. | |
Re: What exactly is the error you are getting? Do you know where it is coming from? Posting 1400 lines of code with no indentation, no comments and poorly used variables names will not help you. You need to be specific with what you want. I doubt someone is going to … | |
Re: Maybe you should put the check for j being greater than zero first. You might be trying to access a negative index. Have you printed out j to check what the value is? | |
Re: for line 121 you have `double shirt_price=0, uniform_cost=0;if(feet <= 6)`. What is the if doing at the end of the line? This will have an impact on all of your other if statements. | |
Re: well one thing i can see is that you never reset the file stream to the begining when you go from your first while loop to your second while loop. You really need to indent your code better. As is it is very hard to follow. Here is an example … | |
Re: Couple things to point out. First `void main()` is NOT standard. main should ony return an int. Second your program is using depreciated headers. If you have an older compiler that does not support the new standard header I would suggest you get a new one. MSVC2010 express and Code::Blocks … | |
Re: do you want the class to be templated or just the functions of the class? | |
Re: You can pass a string to a function that needs a `char *` by using the `c_str()` method of the string class. the `c_str()` function returns a `const char *` that holds what the string contains. in order for this to work the function you are passing the string into … | |
Re: You havent even posted a full program requierment and the code to show what you have done. What do you expect us to do? | |
Re: Welcome to the world of dealing with floating point numbers. My suspiscion is that 1 + 2 as a double is giving you something like 3.0000000000001 which will be greater than 3. If you have a debugger where you can step through your code I would do that to see … | |
Re: How do you think this should be done when using a class instead of seperate function? | |
Re: line 11 should be void printout(ifstream& infile, ofstream& outfile ,string names[numRows],double results[numRows][numCol],double average[numRows]); | |
Re: Depending on what you can use I would use a map to store the posistion and the charecter that needs to be deleted. then you can use the map to delete the unwanted values and to restore them as well. I have implemeted a verxion of this that does work … | |
Re: Are you asking about something like this? if(something) { if(somethingelse) { //... } else { //... ) } else { if(somethingelse) { //... } else { //... } } | |
Re: Well I know you want someone here to teach you but I dont see the point if there are perfectly good lessons somewhere else. http://www.cplusplus.com/faq/sequences/strings/split/ has a very good tutorial on how to accomplish what you need. I would suggest try using what is there and see what you come … | |
Re: It is called a copy constructor because it takes a reference to an object of its own type and creats a new object that is a copy of the object passed into the constructor. take this as an example std::string foo("foobar"); //uses single argument constructor std::string bar(foo); // uses the … | |
Re: Are you getting the wrong answer? Are you getting any compiler errors? Have you tried splitting the equation up to see if you are getting the values you expected? | |
Re: What code do you have? | |
Re: The problem is he wasnt wasnt able to easily get there himself thats why he asked. The person either didnt want to do it or didn't know how so by you giving them the answer it does them nothing but get them further behind in their lessons. | |
Re: Here is some pseduo code that might help int counter = 0 original[] // array you get from user nodup[] // array without duplicates. char ch nodup[0] = original[0] loop i = 0 until size of original - 1 { ch = original[i] loop j = i + 1 until … | |
Re: You need a carry variable to store the addition of `*Num1 + *Num2`. then you need to add `carry % 10` to sum. After that you need to dived carry by 10 to get what needs to be carried over to the next addition. You shout get something like this. … | |
Re: ! Is the factorial symbol. a factorial is defined as `n! = 1 * 2 * 3 * ... * n-1 * n`. Also 0! = 1. You will ned to write a function that will calculate that. If you know how to use a for loop it is pretty … | |
Re: All you need to do is use rand to get a random number in the range of your array and then use that number for the index of your array. Something like this: cout << arr[(rand() % sizeOfArray)]; | |
Re: if (something == token) cout << "You have a token. It is: " << token; | |
Re: Bump a 3 year old thread and put code on it that wont work unless the compiler was made befor 1998? The code you posted wont even work for all casses. What if the order is string 3, string 2 and string 1? No where do you print that combination. | |
Re: What do you mean by having a username made of numbers? Do you want a text username that gets encrypted into numbers? | |
Re: Not to be rude AD but I'll do it for $4,000 USD. A guy has to make money :) | |
Re: switch statements use an int type so if you are storing the value you are getting from the user in a char variable than you need to use a char for your cases. `1` is not the same as `'1'`. Your code should look like this. switch(input) { case '1': … | |
Re: Well you can read in each line from the file and see if you find a match | |
Re: Just get rid of the paramater in the function so it looks like this `void draw();` and then change the function like this void Creatures::draw() { al_convert_mask_to_alpha(sprite, al_map_rgb(255,0,255)); al_draw_bitmap(sprite, getX(), getY(), 0); } This will let you use the sprite variable of the class. | |
Re: you need another char array and after `strcat( sn, ".txt")` you would do `strcat( filenameWithFolder, sn)` | |
Re: What is the output that you are getting? Im pretty sure Walt would tell you this but you should use meaningful titles for your threads. Asking for a specific person to check out your code doesnt really say anything about what is going on. | |
Re: Lines 112 and 116 are using the comparision equal `==` not the set equal `=` operator. Your compiler should be warning you about that. If it is not either use the -wall flag or set you compiler to treat warning as errors. | |
Re: you can also use division and the mod operator to do this. if you want to find out how may 10's you can get out of 87 it would look like this. int amount = 87; int tens = amount / 10; // 87 / 10 = 8 amount = … | |
Re: you need to modify your cylinder class to take in the radius and than pass that to the circle class that makes up the cylinder class. Cylinder::Cylinder(int h, int r) : Circle(r) { height = h; } | |
Re: If you want it to keep going then you would need to put lines 7 through 35 inside a loop. | |
Re: You dont have to put the entire file path if the file lives in the same folder as the .exe file. Only if it is somewhere else than you need to. | |
Re: @ Melou22 - Please start a new thread if you have a question. You will also want to show the code you have so far. We dont give out the answers for homework problems but we can help you get the solution. | |
Re: In programing there are a lot of things that aren’t necessary for you to do. There are also a lot of things that you can do but shouldn’t do. The fact that the language or the compiler you are using allows you to do it doesn’t mean you should. The … | |
Re: your arrays that you are making are to large. If you are on a system that has a 8 byte double than each array is going to need approx 75GB of data. To caluculate this you take the rows x colums x size of data type. That gives you 100000 … | |
Re: You will want to use an array and a while loop to take in the input. to get the sum you would go through the array with a for loop and add all of the values. | |
The End.