2,827 Posted Topics
Re: Yeah, I don't see the word "extends" in your Java code, so I'm doubtful of the inheritance. firstPerson is right regarding pointers and pass-by-value. I'd have to see the overall set-up, but you're probably looking for something ike: [code] class CarNode/*: public Car */ { public: Car* carObject; CarNode* next; … | |
Re: [QUOTE=dotnabox;1038328]How would I use the cin.get() within my overloaded operator? As for the errors, well, I have to build certain messages into it and loop it back around to handle asking for the input again. I'm not worried about that part.[/QUOTE] If you read it in as a c-style string, … | |
Re: Close on the code tags. You need to find "s" OR find "ing", not both. If you have "standing", you want to end up with "stand", right? So once you find, "ing" and delete it, make sure you do not test for "s". string word = "standing"; bool foundIngPrefix = … | |
Re: [QUOTE=Gem74;1037348]how do I print the file?[/QUOTE] [LIST=1] [*]Open the file. [*]Read all or part of the file into variable(s). [*]Display the variable(s). [*]Repeat steps 2 and 3 till end of file. [/LIST] | |
Re: Runs fine for me using 1235 and 3459 as input. They're sum buddies and are reported as such. What input is not working for you? | |
Re: Lines 20, 88. Arrays already are passed by reference. Get rid of the ampersand: [code] void medic(int & money, int [COLOR="Red"]&[/COLOR] potionsize[5]); [/code] Delete the ampersand in red above on line 20 and on line 88. Line 96: [code] int potionsize[5] = {0, 0, 0, 0, 0}; [/code] Declaring a … | |
Re: You're simply merging two files that are ALREADY in order into one output file. Hence only very minimal storage is required (one value from each input file), so vectors are overkill. Have two ifstreams, one ofstream, and two variables of whatever type the file contents are (i.e. int, float, double), … | |
![]() | Re: You should replace [ICODE]A[/ICODE] with[ICODE] test [/ICODE] everywhere inside your function body. [ICODE]A[/ICODE] is a type. [ICODE]test[/ICODE] is the variable itself. [ICODE] test [/ICODE]is an array, not [ICODE]A[/ICODE]. You cannot dereference [ICODE]A[/ICODE] with the [] operator because there is nothing to dereference. [code] void assign_struct(A test[], int id) { // … |
Re: If you use "system", you should import cstdlib, because that's the library "system" is from. But don't use system ("PAUSE") anyway. Use cin.get() once or twice instead. [url]http://www.gidnetwork.com/b-61.html[/url] | |
Re: I think you need to give an example. What's idnum? How does one determine yearbirth from idnum? idnum is an int. There's no "int" class, so the dot operator won't work. [code] idnum.subint (0,2)[B];[/B] [/code] What are you trying to do here? | |
Re: [CODE]#include <iostream> using namespace std; int main() { int TESTS = 0; int testScore[TESTS]; int testNum = 0; int a; double total = 0; double average; testNum = 0; cout<<"How many scores are there? "; cin >> TESTS; cout<<"Enter a score: "; cin >> testScore[testNum]; while(testNum < TESTS && testScore[testNum]) … | |
Re: I'm not sure than sum[] array is initialized except for index 0. also, there is no call to srand, so I imagine you'd get the same results every time. You need to initialize the sum[] array before you use it. | |
Re: [QUOTE=Missy!;1029151]i have a question. why, why do parents go completely Physico about sex. lik wen it comes to their kids, some parents just go skitz. Every time i date a guy my parents want to meet him strate away and they are so judgemental and they give him the hole … | |
Re: Common problem when mixing >> and getline. You need to flush the input stream before the getline command to get rid of the pesky '\n' left by the >> operator. See the [ICODE]ignore [/ICODE] page from cin, and see this thread. [url]http://www.daniweb.com/forums/thread90228.html[/url] [url]http://www.cplusplus.com/reference/iostream/istream/ignore/[/url] | |
Re: One, code tags. Use them. Two, Where's the error and what is it? Point out a line number. Three, is this pseudo-code or real code? Pseudo-code doesn't compile and you shouldn't try to compile it. You have to use the syntax of JAVA for it to compile: `if (fnum is … | |
Re: [QUOTE=razo;1031818]hello, i need ur help.. define a CLASS PERSON TYPE that does: a. set the first name only. b. set the last name only. c. store and set the middle name. d. check whether a given first name is the same as the first name of this person. e.check whether … | |
Re: [QUOTE=restrictment;1031150]Ahh, thank you for the help. However the code is still wrong. The equations: [code] value2[1]=value1[1]*(9/5)+32; value2[11]=value1[11]*(9/5)+32; value2[10]=value1[10]*(9/5)+32; value2[9]=value1[9]*(9/5)+32; value2[8]=value1[8]*(9/5)+32; value2[7]=value1[7]*(9/5)+32; value2[6]=value1[6]*(9/5)+32; value2[5]=value1[5]*(9/5)+32; value2[4]=value1[4]*(9/5)+32; value2[3]=value1[3]*(9/5)+32; value2[2]=value1[2]*(9/5)+32; [/code] are being skipped when calculating Celsius. *I am not working on Fahrenheit atm.*[/QUOTE] These lines are not being skipped. The Fahrenheit values are … | |
Re: [QUOTE=Tom Gunn;1031603]You presume that seeding is a required step, which it is not. Design choices are not the same as memory lapses. ;)[/QUOTE] I'm intrigued. Why would you consider not seeding the RNG here? | |
Re: Here's your code, formatted and in code tags: [code=JAVA] //This is an inventory program that stores //and lists the inventory of Coaxial Connector-fittings //Author: //Class: IT215 //Date: October 17, 2009 package inventory; import javax.swing.*; import javax.swing.JFrame; // provides basic window features import javax.swing.JLabel; // displays text and images import javax.swing.JButton; … | |
Re: These are separate, independent tasks, so tackle them separately and independently. Have two functions, "Flip" and "Reverse". Both involve swapping values, so you'll need to write a "Swap" function. [code] void Swap (char& char1, char& char2) { // put value of char1 into char2 and value of char2 into char1 … | |
Re: If I recall correctly (from a previous thread), the OP also wants each punctuation element to be in its own vector (OP, please clarify), so if the string was "dressed(with))", the OP wants this: [LIST=1] [*]dressed [*]( [*]with [*]) [*]) [/LIST] rather than [LIST=1] [*]dressed [*]( [*]with [*])) [/LIST] so … | |
Re: Pretend you're the compiler. What does the author mean by "two objects are the same"? All their data members have the same value? Possibly, but there could be other definitions too. You'd have no idea, so you'd throw up your hands and quit. The compiler knows what == and != … | |
Re: You should post a short sample text file and what needs to end up happening with that text file. The description is a start, but not quite detailed enough. [code] My name is Bob. I live at 1234 Main St. in Sacramento, CA. My favorite food is pizza! What's your … | |
Re: First step in debugging. Make, make your main look like this: [code] int main () { return 0; } [/code] If that gets rid of the errors, then at least your functions compile, which of course doesn't mean they are correct. If it doesn't compile, start looking at the errors. … | |
Re: [QUOTE=sharkman;1024996]You misunderstood me. I run a compiler on my computer, where I will be creating this program. The computer I will be RUNNING this on will not have one, and is beyond my jurisdiction to install anything on. I wish to turn said program into an executable program FROM my … | |
Re: Well, what are you trying to accomplish? What shape are you trying to make? Map it out on graph paper, with coordinates. These almost all have nested loops. The outer loop draws the lines. If you have seven lines, you'll likely go through the outer loop 7 times. The inner … | |
Re: [QUOTE=javaAddict;1025119] By the way I found one of my posts that I did back at 2008! to be down voted even though the post contained a clear solution to the problem of the OP. I know that like the rep points, anyone can give you whatever points they want, negative … | |
Re: [QUOTE=pspwxp fan;1025358]The compiler shouldn't have just ignored this :/ What compiler do you use? Just so that i don't ever use it.[/QUOTE] = vs. == being ignored has nothing to do with the compiler. It has to do with the compiler flags you set as far as a warning level. … | |
Re: [QUOTE=ki72;1025752]I want to how to to use the constructor CreditCard, how to use the method "getNumber".[/QUOTE] How the hell would we know? | |
Re: Garbage in, garbage out. Before you spend a lot of time analyzing your functions to see where the logic error is in calculating the lowest, highest, and average, loop through your array and make sure it's storing what you think it is. | |
Re: [code=C++] // Test #02 new version // Title : The Question ? // #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int nAnswer; int nAnswer2; void displayExplanation() { //code starts here cout << "The name of the game is\n" << "The Question\n" << "The Object of the game is\n" … | |
Re: [QUOTE=soffie;1023759]Need to make a random size (x = rows, y = columns) matrix which is filled with random numbers (only 0 or 1). So, if I don't know the size of the matrix, I use dynamic array. So far I have made this far, but obviously it isn't quite correct... … | |
Re: This snippet sets aside far more memory than is required, mainly due to the fact that both xsize and ysize are continuously incremented without any checks. Used this way, xsize represents the total number of integers typed in (off by one), not the total number of rows. Type in the … | |
Re: Run it from the command line. If you're running from an IDE, depending on the IDE and the configuration, the console window will disappear when the program aborts due to a fatal run-time error. You need to see the output and the exact error, so run it from the command … | |
Re: I don't see where you're allocating memory in a loop, but yes, dynamically allocating memory in a loop can cause you to quickly run out of memory if you don't remember to free the memory inside the loop. C/C++ has no garbage collector. Unlike non-dynamic memory, you don't get the … | |
Re: [code] while (N>1 && i>=0) { fact = fact * (N-i); i = i+1; }[/code] Yes, i changes, but not in a way that will get you out of this loop. N doesn't change, so this is an infinite loop. Once inside, you'll never get out (well, eventually, after i … | |
Re: If each container holds 5 boxes and each box holds 20 cookies, each container holds 5 times 20 equals 100 cookies. If you get an order for 550 cookies, that's 5 containers, which holds 500 cookies. You have 50 cookies left over that don't fill a container. That's 2 boxes … | |
Re: Line 33 - [ICODE]number[/ICODE] is not initialized and you are using [ICODE]number[/ICODE] to initialize [ICODE]nuCoins[/ICODE], so you are initializing [ICODE]nuCoins[/ICODE], but you have no idea what you're initializing it to since [ICODE]number[/ICODE] is not initialized. [ICODE]number[/ICODE] is initialized in line 39 with the cin statement, but you're intializing [ICODE]nuCoins[/ICODE] BEFORE … | |
Re: [QUOTE=IFEEL;1021612]Hi, why would this not work? (example) [CODE] fileA.h: // declare the function void methodA(); fileA.cpp: // define the function void methodA(){}; fileX.cpp: include "fileA.h" // call it methodA(); <--linker error, can't find the symbol[/CODE] All my headers have the #ifndef guard. Thanks![/QUOTE] Line 13 - is this inside of … | |
Re: [QUOTE=kingbarry90;1021269]hi.. just want to answer wat u told me.. our skul is not just a skul.. our prof. wont provide anything in terms of final requirement.. its all up to us.. im not asking u to give d program to me.. im just asking for idead.. got it??[/QUOTE] Looks like … | |
Re: This isn't a trivial problem. There are quite a few ways to do it. All are a bit advanced for the first day, but hey, this'll expose you to more code. I tried to think of the most elementary way that was still the closest to correct. Specifically I used … | |
Re: [QUOTE=zemly;1018031]Thank you very much. But if you please send me the whole code i'll be very thanks full to you.[/QUOTE] Now you're just messing with people's heads, aren't you? You were just told flat out that that was against the rules, the guy who gave you the code and the … | |
Re: "Reference" has a very particular meaning in C++. It's not interchangable with the word "variable". I don't know whether you used the word "reference" as opposed to "variable" intentionally or not or if your question merely concerns the word "static". Here's a link on "reference". [url]http://en.wikipedia.org/wiki/Reference_(C%2B%2B[/url]) "Static" means a couple … | |
Re: I can't analyze the code you attached since it's in a language I don't know. But here's an example of a very simple encoding technique that simply pads to "encrypt" (not really encryption), and takes out the pads to "decrypt". It uses a character array and isolates characters using the … | |
Re: [QUOTE=Phil++;1018553]So in theory, what I'm trying to achieve is: 1. Set the customers_id (stored in class) [code] s.setID(1) // set customer_id as 1 [/code] 2. Get the search criteria (main.cpp) [code] cout << "Please enter customer ID"; cin >> customer_id; [/code] 3. Search the customers from a list [code] if(s.getID() … | |
Re: Any single if statement using the && operator can be turned into a nested if statement. [code] bool A, B; if (A && B) { // code to execute if A && B } // equivalent to above if (A) { if (B) { // code to execute if A … | |
Re: [QUOTE=pman182001;1017994]I need help with IT210 week 7 programming problems 1 and 2 pseudocode can any one give some advice?[/QUOTE] No one here has any idea what you're talking about. Well, maybe someone does, but I sure don't. | |
Re: Don't create a NEW timer every time in DoJobButtonListener. Your timer does not speed up. Your TIMERS (plural) EACH fire once a second or whatever. Ten timers, each firing once a second, means a count from 10 to 0 in one second. You need ONE timer, created during initialization. If … | |
Re: Lines 25, 30, and 35 are in the wrong spots. You need a broader scope for these variables. They will disappear outside of the for-loops they were created in. Declare and set aside space for your arrays at the top. Then read in at most a line at a time … | |
Re: > Not only have you posted this in another thread, you have yet again ignored the fact you need to put your code in tags. Exactly. Shall we answer here or there? Code tags. Use 'em. Please don't post code again without them. |
The End.