2,827 Posted Topics

Member Avatar for Techboy52

[QUOTE=Techboy52;580498]It compiles just need the buttons to turn the red,green, and yellow light on and off[/QUOTE] This doesn't compile for me. [code=JAVA] import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class TrafficLight extends JPanel { public TrafficLight() { JButton btn1 = new JButton("Green"); JButton btn2 = new …

Member Avatar for JamesCherrill
0
2K
Member Avatar for VernonDozier

Someone a few months ago told me that I had to change a bunch of code from stuff like this... // config_options.h // define _FOO if and only if you want option foo to be available #ifndef _FOO #define _FOO #endif // main.cpp #include "config_options.h" #ifdef _FOO void foo() { …

Member Avatar for VernonDozier
0
788
Member Avatar for Jaypie

What happened to "In the case of deleting an account, we simply cannot honor the request and still adhere to anti-spam laws."? Did they change the law? http://www.daniweb.com/community-center/daniweb-community-feedback/threads/121348/how-do-i-delete-my-daniweb-account

Member Avatar for nitin1
0
547
Member Avatar for queos

The error as far as the compiler is concerned is straightforward. The function wants four parameters. You give it none. There are deeper problems though. What is getSales supposed to do? You have a return statement on line 6. Hence lines 7, 8, and 9 will never execute. What do …

Member Avatar for Bob
0
134
Member Avatar for btbessaay

I guess that if coordinate (3,4) is on a ship, then piecesBoard[3][4] is 'O'. Otherwise it is '#' (i.e. '#' represents water)? Is that correct? Than later, I type in (3,4) and piecesBoard[3][4] is 'O', then board[3][4] is turned into a '%' and I have scored a hit? Is that …

Member Avatar for VernonDozier
0
262
Member Avatar for Secone

If the change to itemamount are expcted to be retained after the function returns, it needs to be passed by reference. Lines 13 and on - Will j ever not be indexMax + 1? If it's indexMax + 1, it's greater than 0. Hence the test on line 14 is …

Member Avatar for VernonDozier
0
236
Member Avatar for owenransen

I haven't done it in quite a while, but my recollection is that you can bypass setting up Server Side Includes and CGI extensions in Apache files, which can be a real pain for people like me who aren't very knowledgable in that, and still have the ability to execute …

Member Avatar for owenransen
0
199
Member Avatar for ShEeRMiLiTaNt

If these are NULL terminated character strings, it seems like your Show function would be a SINGLE loop, not a double, and would display one name at a time, not one character at a time, and each iteration of the loop would contain a newline. char Show(char List[MAX_ROWS][MAX_NAME_LENGTH], int NumUsed) …

Member Avatar for VernonDozier
0
343
Member Avatar for samohtvii

> C has no references C does not have ifstream either. Perhaps the desired conversion is to a `FILE*`? One should not assume that though. The OP needs to clarify the goal.

Member Avatar for Ancient Dragon
0
206
Member Avatar for Pyler

Seems to me that this won't work in either C++ or Java due to Algorithm problems. Take i = 2 for example. That's prime, but according to your code it isn't. n is set as 0 before the j loop. The j loop from 2 to (i-1). In this case, …

Member Avatar for VernonDozier
0
238
Member Avatar for dantheman4

You can test a lot of these by writing programs and trying them out. You list the question and give your answer, but not your rationale. For example... > Suppose a method is declared as: > > public static void f (double d, int n) { > ....; > } …

Member Avatar for VernonDozier
0
186
Member Avatar for ccbuilder

The formatting makes it impossible to read. You have at least one bracket matching error, very hard to see due to the bad formatting. Format, fix the bracket matching errors, and try again.

Member Avatar for VernonDozier
0
168
Member Avatar for GrimJack

[QUOTE=GrimJack;1097407]You know what it means to 'shoot your cuffs'[/QUOTE] You know what it means to "wind a watch". [QUOTE=firstPerson;1097794]when you say, "back in my day...". -------------------------------------------------------- Just for curiosity, whats the age group here in Daniweb? Anyone want to tell their age? I'm 19.[/QUOTE] I'm 39. I'm just starting to …

Member Avatar for vinnitro
1
3K
Member Avatar for letterG

> if(*sen!='a' || *sen!='A' This is always true, yes? *sen can't equal both 'a' and 'A', so it must NOT EQUAL at least one of them. Since you have multiple tests with the || operator, if any of them are true, the statement is true. Hence that if statement will …

Member Avatar for letterG
0
166
Member Avatar for mpyap

> If they enter an invalid entry (not a y or n) I want to go back to the main menu. You want them to go back to the main menu if they enter an invalid entry OR if they enter a 'Y'(that was the original question, after all). > …

Member Avatar for VernonDozier
0
1K
Member Avatar for Microno

Stringstreams are a method of HOW to do something. I'm confused about what precisely you are trying to do. You're creating a program to compute definite integrals. You have a program that apparently works. I'm with you so far. You feel it's "limited" and want to improve it. Understood to …

Member Avatar for Microno
0
172
Member Avatar for VernonDozier

I'm trying to createa function that takes command line arguments, parses them, and returns a stream to be used for output. If a filename is specified, the program will write to that file. If no filename is specified, the default output will be to cout. I haven't gotten to the …

Member Avatar for VernonDozier
0
8K
Member Avatar for Labdabeta

So many jobs are landed through connections. You apparently know a lot of dumb, spoiled, rich teenagers who are presumably the offspring of dumb, older, rich company owners and apparently the Finance Minister Of Canada. You wouldn't be the first person to land a job by impressing someone ignorant with …

Member Avatar for VernonDozier
0
253
Member Avatar for Lostelf

Get rid of the types in the function call (i.e. int, double). Also get rid of the array brackets. Those go in the function definition, not the function call. Line 33 should look more like this. Note the lack of types and the lack of brackets. rc = readHousehold(inFile, idhouseholdArray, …

Member Avatar for Lostelf
0
469
Member Avatar for Qonquest

Not sure where precisely you are printing this string, but it appears to be outside of the Problem5 function. I see a printf statement inside of Problem5, but clearly you are having problems outside of your Print5 function (i.e. the funky character after "This is the source string". Line 37 …

Member Avatar for deceptikon
0
1K
Member Avatar for mpyap

Whenever you mix getline and cin, these kinds of problems show up. You say you've revised the code, but it sounds like you still have at least a few of the same types of problems? They sound like the mixing getline and cin problem. See this thread. http://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream cin leaves …

Member Avatar for VernonDozier
0
134
Member Avatar for juljan30

If you have compiled this, clearly it won't compile. You need to report the errors. "returtn" is misspelled. Why bother having a sum AND a total variable. Just use one. They mean the same thing.

Member Avatar for WaltP
0
126
Member Avatar for mpyap

Lines 8 to 11, 21, and 27. You are creating arrays of size 0, then attempting to store information in those arrays of size 0, hence overflowing the array. If you don't get an actual seg fault, you can expect other problems. Seems like lines 9 and 11 shouldbe moved …

Member Avatar for mpyap
0
175
Member Avatar for gizmo7008

Lines 20 and 21. You have two strings named s with different scopes. You have read a line from the file and stuck that line into one of them in line 20, then you have placed "Hello, World" into the other one in line 21, then on lines 22 and …

Member Avatar for gizmo7008
0
175
Member Avatar for juljan30

You're missing a few brackets, parentheses, etc. Try this. Same code basically, but I added what is missing. #include <cstdio> int main() { int NumArray[] = {2 ,67 ,23 ,5 ,7 ,34 ,14 ,4 ,8 , 62}; int ArrayNum[10]; float SquareNumArray[10]; int oddNum[10]; int i,j, count, cOdd, cEven,max,min; max = …

Member Avatar for VernonDozier
0
165
Member Avatar for hkboateng

private static int Level = 7; private static int Passengers = 10; static int cPassengers = 3; static int cfloor = 3; I see a bunch of static variables that seem like they should be non-static members of the Elevator class. Why create objects if all you do is manipulate …

Member Avatar for hkboateng
0
581
Member Avatar for Reverend Jim

Every other YouTube video I see involves someone taking a movie scene and adding their own music. It's pretty rare that the new music improves things. I'm wondering if people now simply need music with everything and the movie / TV producers are simply giving people what they want (loud …

Member Avatar for VernonDozier
0
182
Member Avatar for poloblue

More details needed. Doesn't run how? 1) Won't compile? 2) Compiles but does not run to completion? If so, how far does it get? How often does it crash? Where does it crash? 3) Runs but gives bad results? If so, what are the correct results, what are the actual …

Member Avatar for poloblue
0
330
Member Avatar for Dani

Toggle button is good. I want the preview, I just don't want the "live/realtime" preview, or I at least want to be able to turn it on and off.

Member Avatar for Dani
0
335
Member Avatar for Dudearoo

#include <iostream> #include <cstdlib> #include <stdio.h> #include <time.h> #include <stdlib.h> #include <iomanip> // so to use strcmp #include <cstring> #include <fstream> using namespace std; int main() { fstream myfile ("savefile.txt", ios::app | ios::in | ios::out); char stringsaveT[90]; string question; if (myfile.is_open()) { cout << "This is a .txt file save …

Member Avatar for Lucaci Andrew
0
649
Member Avatar for VernonDozier

I've been studying up on virtual destructors and how they work and I wrote this little program. I've been adding and removing the word "virtual" on lines 9, 16, and 23 to see what happens. #include <iostream> using namespace std; class a { public: a(){cout << "a::a()" << endl;} virtual …

Member Avatar for VernonDozier
0
220
Member Avatar for Dani

I'm not sure the OP is the best one to determine the best / accepted answer, particularly since quite often they are newbies and therefore could get bad advice that "solved" the problem, be grateful for it, and hence upvote a bad post thinking it was good. Only someone more …

Member Avatar for TrustyTony
0
956
Member Avatar for Dudearoo

Line 15. Your ios flags don't make a lot of sense. In particular "ios::app" and "ios::trunc" being used together seems to cause the problem. Delete one or the other. I can't think of any reason you'd want them both. Look at these flags and the descriptions, figure out what you …

Member Avatar for Dudearoo
0
141
Member Avatar for lewashby

If n, the number of trials is, say, 50,000, you would be randomly generating anumber from 0 to 9, inclusive, 50,000 times, so the hits[] array should sum to 50,000. With ten elements in the hits[] array, the expected value for each element would be 50,000 divided by 10, or …

Member Avatar for VernonDozier
0
169
Member Avatar for VernonDozier

I'm getting an error that I don't understand. It's a Null Pointer Exception, but neither of my arguments in line 118 is null. According to the documentation, ImageIO.write will throw a IllegalArgumentException or an IOException, but it isn't throwing either. I'm not sure what could be null here. You can …

Member Avatar for JamesCherrill
0
2K
Member Avatar for LatSo

> Example is 37373 , 3 is prime 37 is prime 373 is prime 37373 is prime and 37373 is also prime. You have 37373 listed twice. You skip 3737, which is NOT a prime. If you're looking for an efficient algorithm, there's considerable math involved. If not, just go …

Member Avatar for LatSo
0
712
Member Avatar for alsz

> 1 > 1 3 > 1 2 3 > 1 2 3 7 > 1 2 3 5 7 > 1 2 3 5 7 9 > 1 2 3 5 7 7 9 Makes sense up to here > 1 2 3 6 7 7 9 > 1 …

Member Avatar for VernonDozier
0
332
Member Avatar for SAM2012

That's a broad topic with many solutions. For detailed answers, you'll need to ask a more detailed question. You already have a queue in STL, might as well use it. Now "model" and "arrival" mean many different things. Do you want to set up a random number generate with a …

Member Avatar for SAM2012
0
180
Member Avatar for schlulol

Please use one forum or the other for these types of posts or at least link them so people don't waste time aswering here when it's being answered over[ here](http://www.dreamincode.net/forums/topic/282685-explain-how-the-minimax-function-works-for-ai-in-a-game-of-connect-4/).

Member Avatar for m4ster_r0shi
0
316
Member Avatar for khuzdaar

I assume this is a console program, not a graphical program, correct? It seems like you would have to ask for input every time. There is a white player and a black player. You ask the white player where he wants to place the white disk, then you place it …

Member Avatar for faraz ahmad
0
1K
Member Avatar for Dudearoo

Indent your code. It's impossible to read. Are you sure you aren't missing bracket(s)? Why is there are a "return 0" at the bottom of the while loop? Why does the answer "yes" have a "break" statement in it? I thought "no" was supposed to break the loop from your …

Member Avatar for rubberman
0
160
Member Avatar for alsz

ratDen2 will be overwritten if and only if you read it in. If you don't it will remain whatever it was before you asked the user to enter an operation to simplify. The behavior is exactly as you describe. If you don't want to use the denominator of the LAST …

Member Avatar for VernonDozier
0
385
Member Avatar for new_developer

If you want it all in one line, don't output an endl every trip through the loop. cout << i <<" ";

Member Avatar for new_developer
0
1K
Member Avatar for daino

Yes, the linker can do that. I imagine Visual C++ would create the appropriate makefile to compile and link properly. Visual C++ may or may not set things up to help you in that linking. You're going to have to stick this statement... #ifdef __cplusplus extern "C" { #endif // …

Member Avatar for rubberman
0
262
Member Avatar for VernonDozier

This program does not crash but behaves badly due to not allocating enough space for vector z in line 21. If I comment out line 21 and instead uncomment line 23, things work well. If I comment out both lines 21 and 23, the program will crash, presumably because I …

Member Avatar for VernonDozier
0
384
Member Avatar for asif49

Nothing wrong with a smaller company. I imagine it all depends on what exactly you are doing at the company. Just because someone works at a big company doesn't mean they're necessarily doing impressive work at that company. I have never heard that stereotype before and I doubt that a …

Member Avatar for adam_k
0
148
Member Avatar for funkey100

Break line 18 into two lines. char * ccode, = new char [str.size()+1]; char * ncode = new char [str.size()+1]; You need to allocate memory for BOTH strings. I assume that you are adding 1 to make room for the NULL terminator, correct? Beyond that, ccode has the NULL terminator. …

Member Avatar for Schol-R-LEA
0
313
Member Avatar for iAndrewMeyer

If I understand you correctly, the ListPermutations function seems to work as desired. Youpass it "AB" and it displays "AB" and "BA", and that is what it'ssupposed to do, correct? I see the printf statement on line 27 saying that you expect the printout below to also print out "AB" …

Member Avatar for VernonDozier
0
188
Member Avatar for Patiodude

Whether it "can" or not is separate from whether it should. The compiler may allow for "void main", but this explains why it's bad. http://www.daniweb.com/software-development/cpp/threads/10221/why-not-void-main http://www.daniweb.com/software-development/cpp/threads/78955/void-main-vs-int-main and a thousand other threads. A program needs an entry point. "int main" is that entry point, so you need to provide one.

Member Avatar for VernonDozier
0
189
Member Avatar for Dasttann777

cin.get() gets one character, not a string. Perhaps you want one of the other members of the "get" family. http://www.cplusplus.com/reference/iostream/istream/get/ Note than none of them return a string. I imagine you'd be better off using the regular old >> operator with cin. cin >> firstword; cin >> secondword;

Member Avatar for m4ster_r0shi
0
169

The End.