2,827 Posted Topics
Re: [QUOTE=scias23;967263]i just can't figure out what's wrong with this. 1. suppose i enter 9-3-1991 as the birthdate, this should return 18. but it returns 17. //wrong[/quote] [code] private static int ageCalc(int mm, int dd, int yyyy){ // code birthDate.set(yyyy, mm, dd); [/code] I'd have to see the function call, but … | |
Re: atol returns 0 for empty strings and other non-convertible strings. It doesn't distinguish between the user entering 0 and the user entering jibberish. Since 0 is not less than or equal to -1, an empty string will break out of the loop (your revised loop where the test is -1. … | |
Re: First off, you need to figure out exactly what the requirements are. Those will help guide what you need to do. For instance, you mentioned SQL, so I assume there's a database somewhere. You need to know the specifics of that database. If there's no database requirement, there's no need … | |
This snippet is similar to my snippets on how to create random numbers without repeats, particularly[URL="http://www.daniweb.com/code/snippet1034.html"] this one[/URL]. This snippet is different in that it takes an already existing array and "shuffles" it so that the order appears random. No checking is done to make sure that there are no … | |
I received some feedback on my [URL="http://www.daniweb.com/code/snippet1019.html"]earlier code snippet[/URL] regarding how to generate unique random numbers and someone suggested I make a shorter, easier example, so here it is. This example simply generates the integers from 0 to 9 in random order without any repeats. It is basically the function … | |
Very often you find that you need to generate an array of integers where each integer is unique. The program below contains two functions that do that in different ways. One uses a boolean array to keep track of the numbers that have been generated. If a number has already … | |
Re: Pay attention to the warnings (commented code added by me. Original has "int", "double" uncommented): [code] /*int*/ years = Integer.parseInt(fieldyears.getText()); /*double*/ interest = Double.parseDouble(fieldinterest.getText()); [/code] Netbeans gives this warning for both lines above: [code] Local variable hides a field [/code] If you intend "years" and "interest" to be your class-level/field … | |
Re: Also look at all of your other threads on the exact same topic on Daniweb, as well as on other forums. Sometimes people are answering on oher forums at the same time you have them open on Daniweb. [url]http://www.daniweb.com/forums/thread214624.html[/url] [url]http://www.daniweb.com/forums/thread214486.html[/url] [url]http://www.daniweb.com/forums/thread214440.html[/url] [url]http://www.daniweb.com/forums/thread214101.html[/url] [url]http://www.daniweb.com/forums/thread213808.html[/url] [url]http://www.codeguru.com/forum/showthread.php?threadid=483563[/url] [url]http://www.cplusplus.com/forum/general/13911/[/url] People spend time giving you … | |
Re: [QUOTE=shuda009;965302] I know that it has something to do with the number of words in the dict.txt file and the size of my array. If I set the array size to be the same as the exact amount of words then my program will run without fail. However, I am … | |
Re: You used code tags, but there's no indentation so it doesn't help much. Here's your code: [code=JAVA] import java.io.*; class BullsandCows { public static void main(String args[]) throws IOException { int count = 0; int count2 = 0; String str = "fame"; int tries = 0; System.out.println("enter 4 lettered word"); … | |
Re: [QUOTE=power_computer;964739]Ok, so I am working on a function that remove a element from the array if the name entered by a user is = to a element in the array It clears of the memory of said element but i need to re order the array I searched on here … | |
Re: You already have this thread in the Java section. [url]http://www.daniweb.com/forums/thread216043.html[/url] Are you coding in C++ or Java? | |
Re: [QUOTE=Clarkie;965492]Any helpers?[/QUOTE] I downloaded the file and I looked at the thread. Not being familiar with Monster Hunter, I have no idea what all this refers to. The rar file has an executable file and a seemingly jibberish text file. No one is going to run an executable from an … | |
Re: [LIST=1] [*]Thanks for using code tags on your first post. [*]Thanks for formatting your code on your first post. [*]You used meaningful variable names. That's good. People can follow your code more easily that way. [*] You had a paragraph explaining what you did here. Perhaps put that at the … | |
Re: It appears to work fine as long as you don't navigate away from the page, then come back. If you do that, it appears to have problems. At least that was my experience. Perhaps something isn't completed when you leave the page or it's not resuming correctly when you return? … | |
Re: [QUOTE=dnyce 215;965585]In class I have to create a java program that has to use the user method. Here is my code. 1 import java.text.*; 2 import javax.swing.*; 3 import java.io.*; 4 public class Fahrenheit3 5 { 6 public static void main (String [] args)throws Exception 7 { 8 String inFahrenheit; … | |
Re: [QUOTE=akhilesh890;965443]How does the following recursive call work ? max ( fn(x,y),fn(x,y+1)); please give me a clear explanation .[/QUOTE] One, we would have no idea without seeing the max and fn functions. Two, you should start a new thread on this. | |
Re: Code tags. The code looks terrible without them. private Vector Team1 = new Vector(); private Vector Team2 = new Vector(); //Construcor to display GUI for second player to select teams public Selection2(Vector team, Vector team1) { Teams = team; Team1 = team1; panel7 = new JPanel(); label8 = new JLabel(); … | |
Re: [QUOTE=javaAddict;965058]Yes, we are good at it What does this suppose to mean? Have you any idea what you are asking. It's not enough that you cheated at your assignment, you have the nerve to tell us that you cheated and still ask for help. Help not for the code but … | |
Re: Code tags. Code looks terrible without them: [noparse] [code] // paste code here [/code] [/noparse] What's the question? You pasted code with no explanation or question. Does it compile? Does it run? What happens? | |
Re: [QUOTE=Ancient Dragon;964558]I just finished installing Fedora 11 on my 64-bit Vista computer (dual boot) and see that it does not include gcc or g++. I looked on gnu.org, found something that described the gcc compiler package (briefly) but no links to where to download the binaries. Anyone have links to … | |
Re: [QUOTE=Jennifer84;964400]I am doing a fuction where I want to check that a String contains only Letters between: "A-Z" and Numbers between: "0-9" and "_" Instead of checking all one by one. Is there any approach to check against all at the same time ? [code] String ThisString= TextBox1.Text.Trim().ToLower(); for (int … | |
Re: [QUOTE=power_computer;963882] My main problems, it [COLOR="Red"]seems[/COLOR] to read from "song.dat" at execution and when I load the next file i [COLOR="Red"]THINK [/COLOR]the old array clears but it just prints out 0 0 0 0 Edit: I added i = 0; after the file opens in the load function and read … | |
Re: I don't know that your problem has anything to do with the public vs. protected vs. private modiiers in your class, so the thread title may be inaccurate. There are a variety of ways of getting 6 unique numbers. First, get rid of the Strings. You have to parse it … | |
Re: [QUOTE=treyd;962731]I created an array, and I am trying to pass it to a method then double the size of that array. Than I would like to print the array. I am at a loss right now as to why it wont print, and what I am doing wrong. Any help … | |
Re: I can't imagine that these two lines in red are doing anything good: [code] void display(String string) { phrase = string; pan.display(phrase); [COLOR="Red"] add(pan); repaint();[/COLOR] } [/code] You add a PrintStringOnPanel to your JFrame (the same one over and over again, I think) every time the first red line is … | |
Re: I don't know what EasyIn refers to, but I assume it is this? [url]http://mindprod.com/jgloss/easyin.html[/url] Let's look at the spec: [code] Design and implement a program that allows the user to enter into an array the price of a number of grocery products in Euro. The program should then copy this … | |
Re: [QUOTE=Pikachumanson;953770]For example, I want to set flag so that when I click a mouse down a screen schows up. I got that. But when I take my finger off of the button it disappears. Does anyone know how to set up a falg so that doesn't happen? switch(id) { case … | |
Re: [QUOTE=amol14007;962243]Hi, A specific set of range <10,20> <20,30> <30,40> <40,50> i have series of numbers in a buffer; say.. 11 14 19 23 28 45 49 is present in char* noInBuff; Every time if the number falls in specific range for the first time then i have to replace it … | |
Re: [code] if (ComputerStamina < 15) { while (ComputerStamina < 35) { ComputerStamina++; } } [/code] Maybe I am missing the point, but why would anyone want to do this? It's just this, only much slower: [code] if (ComputerStamina < 15) ComputerStamina = 35; [/code] And what are you trying to … | |
Re: [QUOTE=plongx211;960621]how?[/QUOTE] Well, you can start by going into detail as to what exactly you want. Second, post some code, even if it doesn't work, and ask a specific question. | |
Re: [code=cplusplus] while(fin.eof() && count<MAX_SONGS){ getline(fin,songs[i].title); getline(fin,songs[i].artist); getline(fin,songs[i].genre); fin>>songs[i].track_time; count++; } [/code] i never gets adjusted, so you will just keep overwriting the same song here. | |
Re: I don't know if it's a matter of "sending" data from one object to another (by the way, you don't HAVE a Driver object at the moment. Everything's in main, which is static). I'd imagine that it's a matter of having the two objects know how to find each other … | |
Re: [QUOTE=bynaridoom;961192]Ok, what I'm trying to do is have the user enter a command at the prompt, and on the right command a function is called. Here's my code: [CODE]#include <iostream> #include <stdlib.h> void functionCall() { std::cout << "function successfully called"; } int main() { char userInput [128]; std::cin.getline(userInput, 128); std::cout … | |
Re: I mentioned it in your last thread and Ancient Dragon mentioned it in your previous thread. Don't just post code with a title and no question. Doing that inevitably leads people to think that you simply want people to write it all for you and post it. Ain't gonna happen. … | |
Re: [QUOTE=gretty;960694]hello I have some code that loops & takes in a number then should store it in an array. [B]My problem[/B] is that for some reason, the program only stores every 2nd number entered? [CODE=cplusplus] while (!cin.fail() && cin>>purchase) { // while a correct input is input cin >> purchase; … | |
Re: [QUOTE=BlackPhoenix;960479]I tried my hand at C++ client/server programs, but they were extremely difficult, even with the "best tutorial" on the Web (Beej's). I could get a basic client/server program going, but it was with "blocking sockets", and all I knew how to do was get the server to send a … | |
Re: I imagine you want to use drawString from Graphics. [url]http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html[/url] You'll need to turn what you want to display into a String and pass that String, along with the coordinates to display them at, to the drawString function: [url]http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html[/url] From Graphics class: [code] drawString public abstract void drawString(String str, int … | |
Re: If you are not using NetBeans or something similar, start using it. It has a nce code formatting feature. here's your code, formatted in one click, with NetBeans: [code=JAVA] import java.util.*; import java.awt.Container; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.text.DecimalFormat; import java.text.NumberFormat; import javax.swing.ComboBoxModel; import javax.swing.JButton; import … | |
Re: [QUOTE=gcardonav;960073]Hey: I am kinda new to C++. I created this code to display the edge of chaos. Now my professor wants me to graph it in a coordinate system. I know I could use excel and plot it there but I want to learn how to do it using C++. … | |
Re: [QUOTE=Nitroxxerz;945601]I have looked that up before, but the thing is that it deals with arrays which mine doesn't. The codes are written differently, so I don't really understand the other one that well.[/QUOTE] Well, what exactly are you sorting? What's the input and what is the output supposed to be? … | |
Re: Repost using code tags: [noparse] [code=JAVA] // paste code here [/code] [/noparse] Need more details too. What isn't calculating right? What's the input? What's the output? What should the correct output be? | |
Re: [QUOTE=Kioti16;957364]I have this encryption program that I spend hours on. I thought I had it all worked out but no. What could be my problem can anyone help me. You can ignor the void doSet() I will ad that later. Thanks.[/QUOTE] What is this file? [code] in.open("setpCS4.dll"); [/code] | |
Re: [QUOTE=and12;958449]Before i thought all i had to do was add graphics on the background of the panels. [url]http://blogfriendlyzone.webs.com/WheelOfFortune/WheelOfFortune.html[/url] But now when i look at, i think it would need more than graphic background to give it more of a professional look to it so that people would want to play … | |
Re: Presumably you want something like this for your constructors: [code] Sweeper::Sweeper() //default constructor { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) m_box[i][j] = '.'; } } Sweeper::Sweeper(char b) //constructor { for (int i = 0; i < row; … | |
Re: I'm not sure you need a NESTED loop. Seems to me a regular old do-while loop will suffice. However, be very careful of comparing a double to the EXACT value of -1 using ==. I think -1 is one of those values that a double stores EXACTLY without round-off error … | |
Re: [QUOTE=conan19870619;954455]Hi, I have one question. You know some applications can be minimized to the lower right corner and with a hot key (e.g. ctrl+F1). Once the hot key is pressed, the application is activated or some event is activated. I wonder how to do that in java if there is … ![]() | |
Re: [QUOTE=and12;956309]Okay. Sorry for that. I forgot to upload the graphic. I don't think that website is very reliable though because they might tend to delete stuff. Is there a way that the applet could still run and just say Image Not Found instead of leaving me hanging as to what's … | |
Re: Your syntax is incorrect. Those aren't strings. Nor are they string arrays. You can't really delete an element in an array. The space has already been set aside. If you have an array of four strings: [code] mystring[0] = "x"; mystring[1] = "xx"; mystring[2] = "xx"; mystring[3] = "xxx"; [/code] … |
The End.