2,827 Posted Topics
Re: [QUOTE=teddyg18;906632]I have a program in which i open a a text file, access it's values and create and array with it. for example the text file may contain these values: 1 44 3 4 33 6 7 8 61 10 ; that's 10 integers what c++ tools could i use … | |
OK, I haven't done much with Serialization. I have a simple program that creates four JPanels with different background colors and adds them to a larger JPanel using a 2 x 2 GridLayout. That larger JPanel is added to a JFrame. I've written my own serialization code to override the … | |
Re: I don't know whether programmers are stoners, but I feel pretty confident that successful ones aren't stoned WHILE programming. It takes too much concentration and attention to detail, and it's hard work. Three things you don't feel like doing while stoned: concentrating, paying attention to details, and working hard. I've … | |
Re: You add random numbers together the way you add any other numbers together. Initialize a sum variable to 0 and go through a for loop, adding each number. [code=cplusplus] if (n <= 100) {srand(time(NULL)); // seed cout << "Please enter the range you want (lowest to highest) : " <<endl; … | |
Re: [QUOTE=JChakra;908969]Call me stupid mate but I did not get it :P How on earth can I get coordinates from a piece of paper ? I never heard of this trick before please explain. :)[/QUOTE] The odds of you being able able to draw a Bezier Curve by hand on paper … | |
Re: [QUOTE=curi0x;909887]Hi. I'm new to java programming. I have some questions: 1) Does every java source code's [B]class name[/B] (the name after the [I]class[/I] keyword, e.g. [I]class[/I] [B][I]Hello[/I][/B]) has to be started with an uppercase character? 2) Does the java source code's [B]file name[/B] (e.g. [I][B]Hello[/B][/I].java) has to be [U]exactly[/U] the … | |
Re: [QUOTE=joshSCH;806083]simply to give some dumbass poor people who are living on welfare a 10,000 square foot home. [/quote] I assume you can give examples of this? Sounds like the mythical Cadillac-driving Chicago welfare queen urban legend. | |
Re: Are you posting because you have more questions or just to show the final product? It still has major problems. Reread my comments in your prior thread(s). You still have arrays in printGrade. You should have none. You still have a loop in printGrade. There should not be a loop. … | |
Re: I see no arrays in your code. I think you're going to have to re-explain what you're trying to do. I for one don't understand what your goal is or what your question is, particularly this phrase: [quote] a number above my multidimensional array [/quote] What does this mean? How … | |
Re: Lines 10 and 17. You define nCelsius as an integer, then you read it in as integer. If it's NOT an integer, the >> operation fails. Since you can't ASSUME it's an integer (that's the whole reason you're checking), you can't read it in as an integer. Read it in … | |
Re: [QUOTE=zeus1216gw;909785]I know how to make random numbers. and How to make random numbers in a specific range. BUT!!! How can you display 'x' random numbers in a given range and make it so the output display lists the numbers in groups a 'y'. For example: I want to display 25 … | |
Re: tooMany is never used in this function: [code] void readStudentData(ifstream &rss, int scores[], int id[], int &count, bool &tooMany) [/code] You should find out what you are supposed to do with tooMany. readStudentData should do just that: read the student data. It shouldn't display anything except possibly error messages. You … | |
Re: [QUOTE=llemes4011;906810]Hi. When I add a JComponent to my JFrame, it isn't the size of the remaining space in the frame. I want it to work in a way so that when i add a JComponent, it (and it's contents) stretches to fill the remaining space in the screen... Is there … | |
Re: [code] cout<<"enter max number of characters in the sentence"; int number; cin>>number; cout<<"enter a sentence"; char let; [COLOR="Red"]char mycstring[number+1];[/COLOR] [/code] This is actually compiling for me and I'm a little surprised, since I was taught to never do this. Aren't you either supposed to make [ICODE]number [/ICODE]a constant or allocate … | |
Re: DO NOT declare new arrays inside your functions! You've already declared them and provided storage for them in main here: [code] [COLOR="Red"] const int MAX_SIZE = 21; [/COLOR] rss.open("studentData.txt"); string line; [COLOR="Red"] id[MAX_SIZE]; int score[MAX_SIZE]; [/COLOR][/code] Don't do it anywhere else, like here: [code] void readStudentData(ifstream &rss, [COLOR="Green"]int scores[], int … | |
Re: More details are needed and a more precise question. What exactly are you having problems with? The math/physics formulas regarding acceleration/velocity at different ramp angles? The coding of the math/physics formulas regarding acceleration/velocity? Having a figure "walk" at a certain velocity on a line in a GUI (i.e. swing repaints, … | |
Re: > im a newbie in programming,,i cant understand those kind of coding,,can you please solve my problem if you know? The request to use code tags has nothing to do with programming ability; code tags are required because all spacing/formatting is stripped out when you do not use them. Your … | |
Re: Regarding the ternary operator inside the for-statement, I've never been any good with the ternary operator and rarely use it. I've never seen it inside of a for-statement though, which doesn't mean it can't be done, just that I've never seen it. So I can be of no help in … | |
Re: [QUOTE=fourstar;907781]Ok thanks for the help. I got that part figured out now. It turns out I was using [CODE] if(isdigit(numIn[i]) == true) [/CODE] and I shouldn't have been using [CODE]== true[/CODE] Now I'm trying to figure out how to reject any input that is from "G"-"Z" as those aren't valid … | |
Re: Code tags: [code] paste code here [/code] or [code=JAVA] paste code here [/code] There are other classes that you haven't posted so we can't run it. There is no line 10, at least with the code tags that Tekmaven added, so please repost with code tags: [code=JAVA] paste code here … | |
I'm pulling my hair out on this one. It's been a while since I've specified a path for an ofstream. I just want a simple file called "abc.txt" in the C: folder and I want to write "abc" to it. Anyone see anything wrong? Thanks. [code] #include <fstream> using namespace … | |
Re: [QUOTE=einhachi;904450]Sorry- I forgot to include a picture in my previous post.[/QUOTE] I ran it and I got the Java mug and the window, so not sure what's up there. Regarding the fact that you have to forcibly close it, I've never worked with Frames much, and I don't see a … | |
Re: [url]http://www.daniweb.com/forums/thread200252.html[/url] Same poster, same bad attitude. | |
Re: How you do it is going to depend on what you know already. Someone who is familiar with classes would use a class. If you haven't used classes, you wouldn't do that. Similarly someone who has used vectors may well use them instead of arrays. Looks like you are required … | |
Re: [QUOTE=mjf5012;708371]Ok. I have been trying. I am unsure of how to prompt the user to give input without asking a question or entering a statement. This is the 17th assignment and I have been breezing through until now. Can someone please get me started so I can visually see what … | |
Re: Code tags: [code=JAVA] paste code here [/code] It's impossible to read otherwise. public class Student { private String string; private int id; private String[] classList; private double gpa; private double[] gradeList; private double effectiveGPA; private double myGradeType; private double nGrade; public enum GradeType { A, B, C, D, F }; … | |
Re: [QUOTE=akulkarni;904368]i wish to print something like this ******** r ******* er ter uter puter mputer omputer computer where * is a blank space for each line i used array of strings String []s1=new String [20] for 5 blank spaces i used s1+" " + " "..+(5)"" then 4 blank spaces … | |
Re: [QUOTE=Democles;905711]I am attempting to take names and weights from strings and just simply output them. For some reason it can't get out of the while loop, it just sets there waiting for the users to input names and weights. Here's my code [code=C++] #include <iostream> #include <string> #include <vector> using … | |
Re: [QUOTE=zeus1216gw;903593]what kind of other stuff? I'm very new to this so any help it welcome.[/QUOTE] Other stuff like this: [code] b=pow(a,x); c=pow(2.71828, -a); d=b*c; fact*=x; e=d/fact; [/code] You have probabilities, you're using the value of e, etc., other stuff that may USE factorials, but which has nothing to do with … | |
Re: You should be using this function: [url]http://www.cplusplus.com/reference/string/string/find_first_of/[/url] [code] string delimeters = ".?!"; string passage = "ab.cd.ef!gh?ij."; int pos = passage.find_first_of (delimiters); [/code] It'll find the first incidence of '.', '?', or '!', which will be index 2. Then erase the first 3 characters using erase, as you've been doing, and … | |
Re: [QUOTE=siddhant3s;899905]Guess what!! I derived a O(1) formula for the same. If it is your homework, don't try to copy the formula. I am sure you teacher will ask you derive it if you do so. [tex]r=floor\left (\frac{3\times n}{2} \right )-1[/tex] where floor() is the greatest integer function floor(3.2)=3 floor(6.1)=6 floor(6)=6[/QUOTE] … | |
Re: [QUOTE=san26;902701]i have developed coding upto step 5 btt after that i am getting confused..............so plz help and if u want to see my work i can post here...............[/QUOTE] Yeah, post the work here and a specific question. And mark the other thread solved. | |
Re: [QUOTE=Acegikmo;902546]After I've been running my program for a while, it freezes and gives me this error in the console: [COLOR="Red"]Exception in thread "Thread-4" java.lang.IllegalArgumentException: timeout value is negative at java.lang.Thread.sleep(Native Method)[/COLOR] It gives me a line to where the error occurs, which is the same line where it says "try": … | |
Re: [code] #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int int main(void) { unsigned seed = time (0); srand(seed); cout<<"First Array"<<endl; {int a1[45] = {1 + rand () % 45}; cout <<a1[45]<<endl;} cout<<"SecondArray"<<endl; {int a2[50] = {rand () %50}; if (a2[50] % 5 ==0) cout<<a2[50]<<endl;} cout<<"Third Array"<<endl; int max(0); … | |
Re: [QUOTE=lotrsimp12345;902697]i think that using stringstream might work.[/QUOTE] All sorts of things would work. If it were me, I'd read in the whole line with getline, then parse it. Delimiters would be commas and dashes, after you extracted the first letter. | |
Re: [QUOTE=valinux;899448]I have never programmed before or used Linux (didn't even know what that was before a few days ago,) well I got a book for beginning C++ and a book for Ubuntu Linux. My stepdad says it would be best to learn C++ on windows and not to even mess … | |
I have a movie-player type application. You have a movie of JPanels that you can "play", that is you can have the frames change either automatically on a timer or by advancing a frame at a time manually. I've created 4 trivial frames (simple JPanels with different colors). It can … | |
Re: [QUOTE=joshmo;899938]I have a code that calls a method, but after this call, any code after it is not executed....here is the method call skeleton [code=java] if(//some condition){ //some code myMethod(//some variables); //some code/*not executed*/ }[/code] the calling is done well but the code stays in that method i.e code following … | |
Re: You already have an earlier thread on this subject. Have you read the responses? [code=JAVA] robot_instructions[0] = 1; maze[4][5] = 2; maze[6][7] = 3; maze[1][1] = 1; maze[8][8] = 4; maze[3][2] = 3; maze[4][1] = 2; robot_x = 1; robot_y = 1; for(i = 0; i < 64; i++) { … | |
Re: [QUOTE=pmankow;900905]Hello, I am looking to make a program that will generate prime numbers. The program has to start at a specific number, ex: 3698741 and then end at another specific number, ex: 9874123. The numbers may never have duplicate digits, ex: 9874122. There will be a set of rules as … | |
Re: [QUOTE=malugirl4;900421]Sorry this is my first time on this site. Well I dont know if I need that, or if i'm fine with the rest of the code. I just need to add the robot going through the maze and its frustrating cause I know its prob. something simple.[/QUOTE] You're not … | |
Re: You need to have a loop where you extract a digit at a time. You need to know the place (i.e. hundreds, thousands) and the digit (0 through 9). 10 through 19 are special cases, and you'll have to deal with "twenty", 'thirty", "forty", etc., so you'll have some if … | |
Re: Are you using NetBeans or Eclipse? In NetBeans, create a new project, category = "Java", Project = "Java Class Library", then add a new class to the Default Package called "ColorSelect". Copy and paste your code into that file. Do a "Clean and Build" on the project, then go into … | |
Re: Should we post here or [URL="http://www.daniweb.com/forums/thread198833.html"]here[/URL]? You only need one thread. | |
Re: These two code snippets may be useful. No vectors, not goto statements. [url]http://www.daniweb.com/code/snippet1034.html[/url] [url]http://www.daniweb.com/code/snippet1179.html[/url] You're in a tough bind. It's unfortunate that, for some strange reason, many Computer Science teachers insist on using outdated compilers when there are modern, free compilers out there. Probably it's what they are used to … | |
Re: [QUOTE=Pavan_;896187]but i am not including ny header file then how compiler knows about std?[/QUOTE] You don't need to put this line: [code] using namespace std; [/code] The compiler is looking for namespaces and it looks for [ICODE]std::[/ICODE] without you telling it to look for [ICODE]std::[/ICODE]. The following program compiles and … | |
Re: [QUOTE=localp;897130]The code found below takes command lines arguiments and displays. I want to modify this code in anyway that it would take 2 set of command line arguiments and produces 2 outputs. (That means , Open 2 command prompts and run the code) ex: first cmd prmpt -> java CmdLnArgmntExp … | |
Re: [QUOTE=dharm93;896410]Attached is my code. I posted this twice on accident earlier, and I didnt attach the code which caused the users discomfort. My problem is that i keep getting a segmentation fault and I can't understand why. The problem occurs during the decryption part of the program. My other question … | |
Re: I explained how to use code tags here. You need to use them. [url]http://www.daniweb.com/forums/post896175-3.html[/url] |
The End.