2,827 Posted Topics
Re: Put this line at the bottom of [ICODE]actionPerformed[/ICODE]: [code] validate (); [/code] That way you want have to minimize, maximize, etc. Regarding the Layout, I haven't had a chance to look at that yet. | |
Re: [QUOTE=plato_03;954904]hello everyone, this is my first post. I have been teaching myself c++ for the last few weeks and have gotten more familiar with some of it. i thought to myself it would be interesting to try writing up some code that goes through numbers to see if they are … | |
Re: Robot will do fine for this problem, at least for part of this problem. Your main problem is this, I would imagine. Say you have three programs open: this Java program, Notepad, and a browser. At most, one of them will have the active focus. Or none of them could. … | |
Re: [QUOTE=acplus;955004]Did you mean this? else { cout << "File Error: Open Failed"; } It shows me the same error: "File Error: Open Failed"[/QUOTE] The else statement is one line, so it's irrelevant whether you put brackets around that one line or not. You were missing bracket at the end of … | |
![]() | Re: [QUOTE=NeoFryBoy;955013]Simple program opens a text file and counts all the lines. Then it returns the pointer to the beginning of the file and starts pulling in the lines for data manipulation. The Problem: If the file "triangle.txt" ends with a newline everything works fine until the last [i]while[/i] loop which … |
Re: [QUOTE=missty;955009]what is the difference betwwent "|" and "||"?[/QUOTE] || is "logical OR". | is "bitwise OR". From this site: [url]http://www.go4expert.com/forums/showthread.php?t=2891[/url] [quote] OR A bitwise OR takes two bit patterns of equal length, and produces another one of the same length by matching up corresponding bits and performing the logical OR … | |
Re: [QUOTE=esesili;954823]Hi all, I am trying to read double numbers from a txt file and calculate average and standard deviation. It builds successfully but gives an error when it is run. The error I see on the screen is -1.#IND. Do you have any idea what it is and how can … | |
Re: The bracket problems are hard to find because the indentation is so haphazard. I tried to format the code in NetBeans, but it came out all weird. Either it had a lot of problems parsing it due to errors or my setting are wrong. Anyway, here's your code in Java … | |
Re: Sounds like the problem is that your screen never clears so everything you ever painted is painted on the JPanel every time. Nothing gets erased. [code=JAVA] @Override public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; for (Shape s : shapes) { g2.setColor(Color.RED); g2.fill(s); g2.setColor(Color.BLACK); g2.draw(s); } } [/code] … | |
I'm adding really big numbers (a lot of them). I'm supposed to detect overflow errors. I did it years ago in Assembly by checking bits, but I've never done it in C++. [code] long long a = pow (2, 62.0); long long b = pow (2, 62.0); a += b; … | |
Re: [QUOTE=picass0;951825]i trying to write a code which will read from user input of the percentage of some words to be appear. [B][U]example[/U][/B] user will input 50 5 when the program runs. 50 is the total number of runs and 5 means of the total runs it will have 5% of … ![]() | |
Re: If you are searching for a word, the fact that the array is alphabetically sorted would be useful and a binary search would be the way to go. But you're not searching for a word, you're searching for a regular expression within the word. You're also searching for ALL words … | |
Re: [QUOTE=niek_e;951920]How is this a descent reply to iamthwee's post? You reposted your first post, but added the word "tridesclist". Do you think someone is going to think: "Aaah! He's talkink about tridesclistes, this makes perfect sense now!" You'd be wrong. Give us more detail, as requested and also tell us … | |
Re: You have three switch (x) statements, each with one case inside. Have one switch(x) statement with three case statements instead. I don't see a [ICODE]nextChar[/ICODE] command in Scanner, so grab a whole line, then parse the String and grab the fist and hopefully only character in it. You might look … | |
Re: [QUOTE=kspicer;950663]Thanks for the reply, but that isn't what I was trying to do. The output isn't just the number of the counter, it's the particular digit in an array. Once it gets above 10, it's supposed to loop back to 0 and start over. Input/Output [B]0 | 0 9 | … | |
Re: [QUOTE=the great;950227]Hello! I am having a problem in this program.In it a have to calculate the value of π from the infinite series π=4-4/3+4/5-4/7+4/9-4/11+..... by using this formula i have to print a table that shows the approximate value of π after each of the first 1,000 terms of this … | |
Re: Here's [a primer](http://java.sun.com/docs/books/tutorial/java/javaOO/thiskey.html) on this. | |
Re: [QUOTE=ryancfc;950360]I'm just looking to change health, I want to move to SDL but doesn't look like that will happen until I fully understand pointers. Basically I want to change the value of health, I know that health is private because this is the point of Object Oriented Programming.[/QUOTE] Go with … | |
Re: Perhaps more details on the exact program spec and your programming experience? It may have an impact on the advice to give. I am wondering whether this is one of those rare cases where one takes advantage of the fact that switch statements can "fall through" without a break command … | |
Re: [QUOTE=tux4life;949513] Edit II:: So the resume my whole post in one line: [I]You could use structures for this[/I].[/QUOTE] Ha! How much time did it take you to write that one line, Tux? But your posts and the OP's post raise a point. Neither the OP nor tux4life is entirely sure … | |
Re: [QUOTE=cougarclaws;949887]Is there an easier way to understand what this is doing step by step? I get very confused here, and I wonder if any of you fine people have a trick for breaking this down. I really want to get this, and understand the pattern, but what happens in the … | |
Re: You need to use code tags, as mentioned. And you need to format/indent. Your code is impossible to read due to inconsistent indentation, even in code tags. import java.awt.Graphics; import java.awt.*; import java.awt.Graphics2D; public class Main extends javax.swing.JFrame implements Runnable { String m1="hello"; Thread t =null; boolean flag; /** Creates … | |
Re: [QUOTE=smoore;949746]Okay so I posted my [URL="http://www.daniweb.com/forums/post936498.html#post936498"]first large project[/URL]a few weeks ago (2 or 3 i think) and now I finished another one! It is smaller then the 1st (about half the size) but still pretty cool I think. Anyway. It is called uCount and it is something I put together … | |
Re: [QUOTE=llemes4011;949726]Before I say anything else, I do realize that there are numerous threads on this topic, but I haven't been able to fix my problem. Okay. Well, here's my problem. I'm writing a map editor for the game that I'm working on, and the map is oftentimes much larger than … | |
Re: I did it on Dev C++, not Visual Studio. It compiled and ran, but did not work. When I changed the first part to this: [code=cplusplus] fstream writeFile; writeFile.open ("testFile.txt", ios::in); // To test if the file already exists if (writeFile.fail()) { writeFile.clear (); writeFile.open ("testFile.txt", ios::out); for (int row … | |
Re: Use code tags - code is unreadable without code tags and formatting/indentation. | |
Re: [QUOTE=surima;949049]how to generate number and characters together randomly. I know how to generate numbers randomly, but not getting anywhere with random character generation. Please help.. Thanks[/QUOTE] If you can pick a random letter and you pick a random integer, you can pick a random letter or integer, depending on the … | |
Re: [QUOTE=Roguey;947813]I'm trying to write a peice of code that will convert all the uppercase characters in a word to lowercase, and to store that in an array. I know how to convert individual characters, and to output all these characters in the fixed lower case. The thing i'm unsure about … | |
Re: Well this code can certainly be simplified. You don't need all of the cases. A nice formula based on i will do the trick: [code] for (int i=0; i<count; i++) { switch (terminals[i]) { case 1: coordinates[0][i]=(row); coordinates[1][i]=(col); break; case 2: coordinates[0][i]=(2*row); coordinates[1][i]=(col); break; case 3: coordinates[0][i]=(3*row); coordinates[1][i]=(col); break; case … | |
Re: > So this is going to sound like other posts but I have been racking my brain to figure this out. This code is a mod of one that my instructor posted, he said it was fine to just change the names of variables and submit it. When I did … | |
Re: Looking at your first post, it appears that you have a very common problem when mixing cin and getline. See this thread and see if that's about the behavior you are getting. [url]http://www.daniweb.com/forums/thread90228.html[/url] When you have a cin statement, followed at some point by a getline statement, the cin statement … | |
Re: One, do some formatting and indentation. It's impossible to read as it is. [code=JAVA] int x=1, y=1; String Str_1,Str_2; System.out.println("Enter an Equation: "); try { Str_1=dataIn.readLine(); System.out.print("Enter another Equation: "); Str_2=dataIn.readLine(); x=Integer.parseInt(Str_1); y=Integer.parseInt(Str_2); x = x+y; x = x-y; x = x*y; x = x/y; } [/code] Lines 3 and … | |
Re: [QUOTE=skiing;947335]I know that but how about if you are only to enter a seed number one time to initialize the integer generator rand()?[/QUOTE] Then put the seeding before the loop, not inside the loop: [code] cout<<"Enter a seed value : "; int seed = 0; cin >> seed; while(seed < … | |
Re: [QUOTE=gotm;946921]But that one recipe that is in there has a rating of 3/5 stars. The initial rating picture the label uses is the 0/5 stars one. Shouldn't it load with the 3/5 stars picture from that code? Even if I go into the drop down list again, and click the … | |
Re: [code=JAVA] booean doneEnteringData = false; while (!doneEnteringData) { String name; double salary; int month; // ask for name if (/* name is empty */) doneEnteringData = true; else { // ask for month and salary and do whatever you do with it. } }[/code] | |
Re: Lines 60 - 64 : Don't add and remove elements from the Applet. You already have a JLabel called Result. Keep it. Just change the text inside of it. [code=JAVA] String textNumber = Integer.toString (randomization); String newLabelContents = ultimo + textNumber; Result.setText (newLabelContents); [/code] Line 51 - You may want … | |
Re: [QUOTE=Hawkpath;944643]wow, thanks a lot. :) . I'm a beggining programmer (As you could probably tell) so allthat kinda blew my mind but thanks anyways[/QUOTE] Good explanation by Tom Gunn. Some of it may not make much sense if you haven't run across templates or classes or structures. We don't know … | |
Re: [QUOTE=amarucla;944984]You can use "map" container from STL which automatically sorts its contents by the key. First split each your lines by "|" token, using tokenizer command of c++, then store each line in the map with course code as key and the full line as value. The map finally contains … | |
Re: [QUOTE=Nathan Campos;944715]Hello, I'm learning Java and i want to build a program that save emails to an [i]*.txt[/i] file, like this: One guy send me an email, then the program periodically search if i have emails every 10 minutes and if i have it saves all the emails in a … | |
Re: [QUOTE=tarekwehbe;944696]thx for nothing guys first time i post no help hehehe what a forum ... for the guys who replied i only asked for error 6 to 12 which take approx 5 min for an experianced programmer .... talking to me about morrality like im the immoral person....well if some … | |
Re: [QUOTE=sara khan;944655]can u tell me from where I can get more information about file handling and the functions of it..[/QUOTE] Google it! "C++ peek" gives the following as the first link. [url]http://www.cplusplus.com/reference/iostream/istream/peek/[/url] Bookmark the entire site. [url]http://www.cplusplus.com[/url] It's your first stop before you ask a question on a forum. Type … | |
Re: If ComputerPart is the name of a class and you want to return an instance of that class, then getComputerPart shouldn't return an Integer. It should return something of type ComputerPart. Is there a class called ClassB somewhere? Regardless, parseInt returns an int. What are you TRYING to do? You'll … | |
Re: Line 3 - Someone mentioned this earlier. Get rid of the space. Should be: [code] #include "EmployeeClass.cpp" [/code] not [code] #include "Employee Class.cpp" [/code] Don't mistake a warning for an error: [quote] warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. : see declaration of … | |
Re: Yes, please read the rules regarding code tags and chat-speak as well as this thread: http://catb.org/esr/faqs/smart-questions.html Here's your code: #include <iostream> using namespace std; void displayMenu() { system("cls"); cout << "+-------------------------------------+" << endl; cout << "| TetraPek Inc. |" << endl; cout << "|=====================================|" << endl; cout << "| Select: … | |
Re: Without seeing your sample input files and, more importantly, the original problem/program specification, and not knowing what the program is supposed to do, it's hard to offer any advice. What does Code Chef say is wrong (or does he/it say elaborate? I'm unfamiliar with Code Chef)? A link to the … | |
Re: [QUOTE=gopi17;942608]the problem is i'm not allowed to use arrays... [/QUOTE] Why not? One can always get around this stuff by using a vector instead that functions as an array, but I imagine that's cheating. There must be some reason why you're not allowed to use an array. I don't know … | |
Re: [QUOTE=sara khan;937043] i dont understand how the output is generated.. please help if anyone understand this....[/QUOTE] Which part of the output? I glanced over the assignment. First, there's a math aspect of the problem. You need to model/solve that and that is independent largely of the C++ programming implementation. Second, … | |
Re: [QUOTE=Nathan Campos;942947]Hello, I'm trying to get a string from a thing that is inside quotes as you can see [URL="http://www.daniweb.com/forums/thread209962.html"]here[/URL], but when i try to compile i got this errors: [code]ubuntu@eeepc:~/C++/Tree$ g++ -o tree tree.cpp tree.cpp: In function ‘int main(int, char**)’: tree.cpp:65: error: ‘get’ was not declared in this scope … | |
Re: You posted code, which is good, but didn't tell us whether the code works or what the input file should be, how to use your program, which part of the code to concentrate on, stuff like that. I'm not entirely sure what you want, but I think that this is … | |
Re: I'd have a struct like this: [code] struct quizQuestion { string question; vector <string> possibleAnswers; string correctAnswer; }; [/code] Then have a vector of [ICODE]quizQuestion[/ICODE] that makes up the quiz. |
The End.