2,827 Posted Topics
Re: [QUOTE=soulbee1;846353]Forgive my ignorance, I am learning. I am writing a C++ BlackJack program for school project. I have googled and incorporated the following code into my project. My results are I am getting a value for the cards of 2 - 5 and i do not understand why. If someone … | |
Re: Lots of good Tic Tac Toe threads on Daniweb. There are a variety of ways to approach it. Break it up into smaller, more manageable tasks. For instance, I would start with a function that accepts input from the human player. You should probably make it a member function of … | |
Re: Okay, so you have functions that encrypt and decrypt. Both of these functions take a parameter called choice, which isn't used. You talk about files, but I see no ofstreams or ifstreams. There is a password that I assume is not encrypted and which functions as the encryption/decryption key. Presumably … | |
Re: You don't need [ICODE]drawP[/ICODE]. Add [ICODE]this[/ICODE] to the frame, not [ICODE]drawP[/ICODE]. Ditto with the MouseListener. Add the Listener to [ICODE]this[/ICODE]. | |
Re: I'd say it means show every time that the order changes. For example, in a selection sort, it could be this: [code] 3 4 5 1 2 1 4 5 3 2 1 2 5 3 4 1 2 3 5 4 1 2 3 4 5 [/code] I made … | |
Re: [QUOTE=Dave Sinkula;705374]I don't know where to start, so I'll start [URL="http://www.bookwormroom.com/2008/10/04/conservatives-think-liberals-are-misguided-liberals-think-conservatives-are-evil/"]here[/URL]. Let's let liberals/progressives define themselves, and conservatives likewise. But seriously, this reeks of such intolerance, I cannot fathom anyone labeling this "progressive" or "liberal".[/QUOTE] The Republican Party has successfully redefined liberal and progressive to the point that, whatever it … | |
Re: [QUOTE=clutchkiller;789437] I'm just saying im moving to either Canada or somewhere in Europe... FYI: im not ignorant, I just love how clueless everyone is about any kind of politics and am disappointed that even at the DNC, any of the public that was interviewed about what they thought about obama, … | |
Re: So the goal is to have a function like this? [code] string RemoveWinampFromString (string beforeRemoval) // if given "Korn - Evolution - WinAmp -2:00 / 3:30", // should return "Korn - Evolution - 2:00 / 3:30" [/code] | |
Re: Thank you for using code tags! [code] void Employee::set(double payRate, int hours) { cin >> payRate; cin >> hours; } [/code] It seems to me you should either have a set function that takes parameters but doesn't have cin statements, or a set function that has cin statements but takes … | |
Re: [code=JAVA] for (int cclick=0; cclick<1; cclick++) { if (cclick==0) { globals.executesqlcom("insert into tblorders(cabin,seatnum1,seatnum2,item,price,qty) VALUES('" + globals.cabin + "','" + globals.seatnum1 + "','" + globals.seatnum2 + "','Travel toothbrush and toothpaste',.00,1" + ")"); MyMessage.showMessageDialog(this, "Freebies Added to Cart"); cclick = cclick + 1; } else { MyMessage.showMessageDialog(this, "You can only avail one … | |
Re: Code tags and formatting/indentation please. [noparse] [code=JAVA] // paste code here [/code] [/noparse] Your code is below, but it's still hard to read since there is no indentation. Second, what is the question? [code=JAVA] import java.lang.Math.*; class DrunkWalker { /***************** * data items ******************/ private static char ch[][] = new … | |
Re: [QUOTE=Ancient Dragon;822634]Actually I started this thread as a spoof on the theory of evolution, not intended to be a serious discussion of anything. If you watched the utube video I posted you would have seen that.[/QUOTE] Looks like they took the original link down. However, post # 2 in this … | |
Re: [code] public [COLOR="Red"]static[/COLOR] void main (String args[]) { // code here } [/code] You forgot the [ICODE]static[/ICODE] keyword. | |
Re: [code] ostream& operator<<(ostream& os, const List& l) { os << "< "; [COLOR="Green"]Node *[/COLOR]temp = l.start; temp->getAuthor(); while (temp) { os << temp->getData() << " "; os << temp->[COLOR="Red"]getAuthor[/COLOR](); temp = temp->getNext(); } os << ">"; return os; } [/code] [ICODE]temp[/ICODE] is of type [ICODE]Node*[/ICODE] (see green above). The function … | |
Re: You have a class called VideoTitleRating, containing a method called displayArray. You create an object of type [B]BubbleSort[/B] and then call its [B]displayArray[/B] function. Are you intending to call VideoTitleRatings's [ICODE]displayArray[/ICODE] function instead? Is there a reason you have a [ICODE]BubbleSort[/ICODE] [B]class[/B]? How about making a [ICODE]BubbleSort[/ICODE] method within your … | |
Re: [QUOTE=nucleon;842680] Get rid of the "SEE YOU LATER" at the end. (Why do beginners always do that?)[/quote] For some reason, I like stuff like that. [QUOTE=nucleon;842680] Do not put copyright notices in simple code like this (or anything you write for the next four years).[/QUOTE] It's never too early to … | |
Re: Not sure what the [ICODE]countNegative[/ICODE] function does or why you are calling it. I also don't see the purpose or the need for the [ICODE]next [/ICODE]variable. What is [ICODE]startIndex[/ICODE]? There's also nothing recursive about this function. I don't see any call to [ICODE]countfive[/ICODE]. | |
Re: [QUOTE=weasel7711;837200]You have 9 billiard balls. They are all the same weight, save one. You want to find out which one is heavier. All you have is a scale that determines the heavier side. You can weigh any number of balls at any time. What is the least amount of weighings … | |
Re: [QUOTE=richhoggan;841122]I am working on a programming assignment for class and having a little trouble. The biggest trouble I am having is working with arrays and doing the hex calculations, then making the conversion back to decimal. I have included the assignment description below: Write a C++ program to perform addtion … | |
Re: Can you restate the problem because it's a bit unclear what the goal is and what the actual behavior is (at least to me)? Also, please upload the main function and anything else needed to run the program so we can try it out. Thanks. | |
I am trying to learn GridBagLayout. I've gotten the hang of it in many respects, but I am having serious problems when the first row has element(s) with a gridwidth greater than 1 or the first column has elements(s) with a gridheight greater than 1. I'm trying to make a … | |
Re: Code tags and formatting please. import java.util.Random; public class lab11a_killackey { public static void main(String args[]) { Random randomNumbers = new Random(); int a[]= new int [ 1000 ]; a [1000] = 1 + randomNumbers.nextInt( 51 ); int big = -1; int small = 52; int n; for (int i=0; … | |
Re: Do not compare a double to a double using the equality operator. It's extremely unlikely that the two numbers will be exactly the same. Instead, set up a tolerance and quit once you get there. [code] double piestimate = 0.0; double TOLERANCE = 0.0001; double piroundoff = 3.14159; while (Math.abs … | |
Re: You are using a GridLayout, so it seems to me that it's fairly easy to get the coordinates. The width of a button is the width of the panel divided by the number of buttons per row (4). The height of a button is the height of the panel divided … | |
Re: [QUOTE=jacline;839508]When i delete the variables in Draw it works i become happy but it works wrong:S I cant find my fault but i continue trying thnks for your help:)[/QUOTE] The slider part works fine now, it appears (though I'd have it range from -10 to 10, with ticks every 0.2 … | |
Re: [QUOTE=doha786;839519]in C language i learned Precision paramater to show how many decimal point to print... in java how to do this precision for double, float etc....................[/QUOTE] I imagine your best bet is to play around with DecimalFormat and NumberFormat. [url]http://www.dreamincode.net/code/snippet399.htm[/url] [url]http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html[/url] | |
Re: [QUOTE=custurd12;838733]okay, but now im getting multiple errors[/QUOTE] We can't see what you've done since the last post, so please post the updated code and an updated description of the problems. | |
Re: [QUOTE=johdoe;838260]Greetings, I have the following class [ICODE] class test { public: test():element(NULL), previous(NULL), next(NULL){}; void *element; test *previous, *next; }; [/ICODE] this works fine: [ICODE]test * a_test[/ICODE] but this crashes: [ICODE]test a_test[/ICODE] does anybody know what it is that i am doing wrong? I am sure its something that has … | |
Re: Are you sure this is the right specification? [code] MoneyType MoneyType::DollarsAndCentsAre(MoneyType value) const [/code] and are you sure it's supposed to only display something (i.e. not calculate something)? If so, it seems to me that this should be the specification for a function that simply displays: [code] void MoneyType::DollarsAndCentsAre() [/code] … | |
Re: You need to say what the problem is. It's not going to compile, but please state that and give the location and the error messages and a detailed question. For starters, this is C++, not Java, so you need a colon after public and private and you don't have to … | |
Re: [QUOTE=dep.new;837243]ok, there isn't but what about other programming lang? can they do that? thks :)[/QUOTE] I think you're going to have to explain the problem a little more clearly. An example of a language that uses operator overloading is C++, but I don't understand what you are trying to do. | |
This isn't a programming how-to thread, but I've written a large graphics manipulation program in Java and I am developing a help section that explains how to use the program, a step by step tutorial for how to use all the features. I figure a good way for me to … | |
Re: [code] bool arrayComp(int firstArr[], int secondArr[], int size) { for(int i = 0; i < size; i++) { if(firstArr[i] != secondArr[i]) { arrayEqual = false; break; cout << "You have entered a wrong PIN!"; } return arrayEqual; cout << "Welcome to The National Commerce Bank!"; } } [/code] One, you … | |
Re: You are mixing tabs and spaces on the indentation, which leads to problems when posting on Daniweb since a tab is 8 spaces here. What exactly is being sorted here? [code] void sortAr(int zid [], double pgmavg [], double testavg [], int size, char sortchar) { int i, j, min, … | |
Re: Start by looking at this class and deciding exactly what you want here: [code] class RoomDimension { private: int w; int l; public: FeetInches width; FeetInches length; }; [/code] You have two pairs of width/length here. Why? Better to store only one and to convert from inches to feet/inches and … | |
Re: [QUOTE=DanielB2;836983]Hi all, I have created a Backgammon AI player in Java, and I would like to know if anyone knows how I can play my player vs GNU Backgammon in order to test how well it does. Thanks[/QUOTE] You probably have to physically play GNU Backgammon as a human, enter … | |
Re: [QUOTE=jimbob90;836688]I haven't programmed in some time and need some help here plz. First of all how are individual characters of a string are accessed? second do they start at 0 or 1? I'm probably confusing this with arrays please help me out :). This program will read in a line … | |
Re: [QUOTE=lehe;836644]Hi, I was wondering: if the memory allocation in the following codes is static or dynamic, why the upper limits on their sizes are different, why some of them would cause segment fault? what you would suggest to allocate array according to different need? 1. [code] double data[1048000]; for(int i=0; … | |
Re: [QUOTE=rahul8590;836361]Hey every one , well i was writing program which inputs "[B][U]Statistical data for example x 1 2 3 4 5 y 1 4 9 16 25 and analysing the data my program must suggest a suitable algebraic equations like looking at this one it should tell me the equation … | |
Re: [QUOTE=beth2138;835906][code] Help...how do i do this i am totally stuck, would you be able to show me?!?! :S Please [/code][/QUOTE] Here's a skeleton: [code] // array[] is an array of Integer. int maxNumber = array[0]; // intialize to first element for (int i = 1; i < array.length; i++) { … | |
Re: [code] [COLOR="Red"]float[/COLOR] totalHouseCost (float initial, float fuel, float taxRate) { float totalFuelCost = fuel * 5; // Fuel for 5 years float totalTaxes = taxRate * initial * 5; // Taxes for 5 years float totalCost = initial + totalFuelCost + totalTaxes; /*Initial House cost + fuel cost for 5 … | |
Re: [QUOTE=DanielB2;835682] I was converting from Java initially [/QUOTE] That explains this error: [code] for(int i = 0;i<diceArray.[COLOR="Red"]length[/COLOR];i++) [/code] There have been several threads on Daniweb regarding whether you can determine the length of an array from the array itself in C++ and they've almost all said that you can't do … | |
Re: [QUOTE=abhi_elementx;834974] What can be the grammar for a telephone number and name considering that [COLOR="Red"]users shud not enter[/COLOR] spaces, wild chars, [COLOR="Red"]alphanumeric chars[/COLOR], etc... [/QUOTE] How can you enter a phone number without using alphanumeric characters (i.e. digits)? | |
Re: The code and the description are pretty confusing to follow. [code=JAVA] //Pizza Object Pie one = new Pie(); //Type of pizza - Using Input for what pizza ya want System.out.println("Please Enter In The Pizza you wish to make: "); one.type (); //Dot operator to set slices of pizza one.slice (); … | |
Re: This program ran correctly for me. Do you get an error? [code] #include <iostream> #include <string> #include <iomanip> using namespace std; int vis(string code4) { string temp; double a, b; if (code4[1] == '/') { a = code4[0] - '0'; b = code4[2] - '0'; double k = a/b; cout … | |
Re: To The OP, It may be helpful for you to perhaps explain in more depth what you are trying to accomplish. I don't understand what you are trying to do here: [code] private String[][]Ram = new Ram[10][1048] Ram[0] = String[0-99] Ram[1] = String[100-199] Ram[2] = String[200-299] Ram[3] = String[300-399] Ram[4] … | |
Re: [QUOTE=devfolarin;834161]also could you elaborate on the if board[x][/QUOTE] [code] for(x = 0; x < 9; x++) board[x]='-'; [/code] I believe SeeTheLite's point is that the above is superior to doing this: [code] board[0] = '-'; board[1] = '-'; board[2] = '-'; board[3] = '-'; board[4] = '-'; board[5] = '-'; … | |
Re: I think you are on the right track. You can add code beforehand to deal with the ten thousands, thousands, and hundreds, and it can be quite similar (practically identical) to what you've done before when dealing with 1 through 9. [code=cplusplus] // assumes dollars < 1000 by this point … | |
Re: Code tags please. You can edit your post and add them. [noparse] [code=JAVA] // paste code here [/code] [/noparse] So it compiles fine and those are run-time errors? | |
Re: [QUOTE=redmaverick;830995]Hi guys! Its working now........ I read somewhere that we have to restart the system to make it pick the path....... this has caused me frustration to no end....so don't forget to RESTART...... bye![/QUOTE] I'm not sure you have to restart. You just have to make sure that you open … |
The End.