2,827 Posted Topics

Member Avatar for DeadJustice

Please be more specific about what the problem is. What is this function supposed to do and what does "it completely scrambles up my board" mean? [code] //Determines the amount of mines adjecent to a cell: BUGGY void findMineValues(){ for( int i = 0; i < 10; i++ ){ for( …

Member Avatar for DeadJustice
0
2K
Member Avatar for tyoung4@runner

[QUOTE=tyoung4@runner;812131]Hello everyone. I am having a hard time getting this program to run w/o an infinite loop. I have been in my C++ class for a month. I think my test expression is incorrect, but I've tried what I think it should be. Problem: Write a program that asks the …

Member Avatar for tyoung4@runner
0
267
Member Avatar for smoore

[code] for(int i = 0; i < numOfPoints-2; i++) { area += (xPoints[i]*yPoints[i+1])-(xPoints[i+1]*yPoints[i]); } area /= 2; [/code] The formula tells you you need to range from 0 to the number of points - 1, not the number of points - 2. I imagine that vertice n is really vertice …

Member Avatar for smoore
0
1K
Member Avatar for rudasi

[QUOTE=rudasi;814419]Hello, I just had a midterm and there was a question where we had to right a program which can calculate all the numbers which form quadruplets. A quadruplet would be x^3+y^3+z^3=a^3 The program should only run till a<25 also, 0<x<y<z<a at the end we had to output how many …

Member Avatar for siddhant3s
0
207
Member Avatar for FyerEgg

What input did you give it, what was the actual output, and what should have been the output?

Member Avatar for ArkM
0
152
Member Avatar for di mo

Please repost with code tags and formatting. [noparse] [code=cplusplus] // paste code here [/code] [/noparse] That's a lot of code to wade through for a fairly vague question. Can you be more specific on what the problem is and pinpoint where to look in the code?

Member Avatar for di mo
0
457
Member Avatar for VernonDozier

I have a program that is supposed to draw circles every twentieth of a second every time a button is clicked. When the button is pressed, a function is called and a for-loop is executed 25 times. Within that for-loop, [ICODE]repaint ()[/ICODE] should be called. Within the [ICODE]paintComponent[/ICODE] function, random …

Member Avatar for VernonDozier
0
546
Member Avatar for sweetApple

You have several things going here. You have the agent class. Within that class you have a world class, which is the world as the agent sees it. Is that any different from the world as it really is? In particular, the 5 x 7 grid? Basically, I am wondering …

Member Avatar for sweetApple
1
139
Member Avatar for jdbarry

Looks like you are mixing spaces and tabs, which makes the formatting look bad when posted on Daniweb. The average of anything, whether calculating PI or otherwise, is the total of all the trials divided by the number of trials. So start a "total" variable, initialize it to 0, then …

Member Avatar for VernonDozier
0
276
Member Avatar for devonte15

[QUOTE=devonte15;810837]This is the question? The German mathematician Gottfried Leibniz developed the folling method to approximate the value of pi: pi/4 = 1 - 1/3 + 1/5 - 1/7 + ...... Write a program that allows the user to specify the number of iterations used in this approximation and displays the …

Member Avatar for VernonDozier
0
1K
Member Avatar for FEARmike21

Code tags: [noparse] [code] // paste code here [/code] [/noparse] [code] double r = cin.get; [/code] [url]http://www.cplusplus.com/reference/iostream/istream/get.html[/url] If this is a function call, you need parentheses. [code] double r = cin.get; [/code]

Member Avatar for rudasi
0
95
Member Avatar for Argo54325

It looks like you have a bunch of debugging info in the program, which is fine for debugging purposes, I suppose, but it means it's not entirely clear to the outside observer what the actual code is and what is debugging code that just hasn't been taken out yet. I …

Member Avatar for VernonDozier
0
1K
Member Avatar for mikemea

[QUOTE=mikemea;810432][B]cannot convert parameter 1 from 'char' to 'char *'[/B] calcCharges(type_of_gas, &rate_of_gas, number_of_gallons, &total_gas_of_price, car_wash, &price_of_car_wash, &total_cost);[/QUOTE] Looks like it should work to me! :confused:

Member Avatar for ArkM
0
77
Member Avatar for Argo54325

We can't run it since you haven't provided the the input file(s). What exactly is the program supposed to do? For particular input file(s), what is it SUPPOSED to output and what DOES it output?

Member Avatar for Argo54325
0
106
Member Avatar for Lamar Cole

[QUOTE=Lardmeister;805803]No man is truly married until he understands every word his wife is NOT saying.[/QUOTE] Then no man has ever been married in the history of the world. No man has ever understood every word his wife/girlfriend has ACTUALLY said, much less every word she HASN"T said, much less what …

Member Avatar for sneekula
0
171
Member Avatar for scias23

[QUOTE=verruckt24;805872]As mentioned in my previous post, I have for long lost touch with C++, but I assume from what I know, that none of the current collection of GNU compilers use the .h suffix. The new crop of compilers are bound to throw an error at you for that.[/QUOTE] Yeah, …

Member Avatar for jencas
0
285
Member Avatar for dbwalters

Line 205? Where's line 205? Please repost using Java code tags. which will add line numbers, or highlight line 205 in red. [noparse] [code=JAVA] // paste code here [/code] [/noparse]

Member Avatar for hrdzdier
0
827
Member Avatar for hurbano

You have two threads on the same topic. [url]http://www.daniweb.com/forums/thread176040.html[/url] Mark one solved so people know where to comment. Yes, you are way off. Read my post on the other thread for some of the reasons why. I don't think this is what ArkM meant by the separate cpp file (what …

Member Avatar for hurbano
0
2K
Member Avatar for sonicstage

Code tags: [noparse] [code] // paste code here [/code] [/noparse] [code] #include <iostream> #include <cmath> using namespace std; double mma (double Nums[], int inSize, double max[], double min[]); double std_Dev ( double Nums[], int inSize ); double avg = 0, sDev, sum = 0, sum2 = 0; int main ( …

Member Avatar for verruckt24
0
100
Member Avatar for infernojmd

[QUOTE=infernojmd;807426]ok so my compiler is doing something weird, for this like of code it is thinking the \d is a command like \n but that is a cstring, and it uses each char to decode a message to Attack at dawn!, but comes out missing the c, any hits or …

Member Avatar for stephen84s
0
116
Member Avatar for danielle23

[code=cplusplus] //what is being printed void print (char board [3][3]) { char r,c; //current row and col for (r = 0; r < 3; r++) { for (c = 0; c < 3; c++) cout << " " << board[r][c]; } //This is the start of the board setup...I got …

Member Avatar for VernonDozier
0
1K
Member Avatar for hurbano

Code tags please: [noparse] [code=cplusplus] // paste code here [/code] [/noparse] The object is to be able to do this in main: [code] monthsSet a; monthsSet b; a += b; [/code] so it compiles and runs. Currently you have to do this: [code] monthsSet a; monthsSet b; a.unionSet (b); [/code] …

Member Avatar for VernonDozier
0
441
Member Avatar for mimis

[QUOTE=mimis;805101]Ok, but how can i find the most likely paths?[/QUOTE] You have to define "most likely path" and decide whether it is pertinent to your needs. If you need to find [B]THE[/B] shortest path, it isn't. There is a wealth of information on Shortest Path problems out there. You need …

Member Avatar for mimis
0
405
Member Avatar for noty1

[QUOTE=noty1;805791]im looking for a code that shows how the directed graph is being implemented in C++ classes. i havent figured out the algorithm to be used. all i know is the concept of directed graph. edge() and vertex() function will be created in a class. all i need to know …

Member Avatar for VernonDozier
0
107
Member Avatar for oldSoftDev

You have words like "Bob" in your text file. If the program is looking for a floating point number and runs across "Bob", you are going to get an error.

Member Avatar for Ezzaral
0
96
Member Avatar for tksrules

[QUOTE=tksrules;804734]I did compile by parts but i can't just get going with the CalCost() function.I think i am commiting mistake there.[/QUOTE] Comment out everything but the "return 0" line in main, see if it compiles. If it does, start uncommenting lines one by one till it doesn't compile, then look …

Member Avatar for VernonDozier
0
352
Member Avatar for confused_in_CO

Code tags usually make it much easier to read, but in your case, there is no formatting either so it doesn't help much. Format your code and repost it in code tags please. [noparse] [code=cplusplus] // paste code here [/code] [/noparse] [code=cplusplus] void remove_extra_spaces(ifstream& in_stream, ofstream& out_stream) { char next, …

Member Avatar for confused_in_CO
0
79
Member Avatar for k2k

I see you used WaltP's suggestion rather than mine. That's okay. My feelings aren't hurt.:( His suggestion was actually better. [url]http://www.daniweb.com/forums/thread109017.html[/url] I think you mean [code] '\0' [/code] rather than [code] '/0' [/code] You are using a string rather than a C-String, so I wouldn't worry about NULL terminators. I …

Member Avatar for VernonDozier
0
129
Member Avatar for friollano

I see a "Yes" arrow attached to the "End Of File?" diamond, but no "No" arrow. The "Yes" to "End Of File" arrow points to "Read the Next Record".

Member Avatar for VernonDozier
0
80
Member Avatar for ajkraft21

[code] while (row++ > 0) cout<<"*"; [/code] If you ever get into this while-loop, will you ever get out of it?

Member Avatar for winrawr
0
131
Member Avatar for curtissumpter

[QUOTE=curtissumpter;802419]Is it safe to assume that any object that is preceded with the letter 'J' is a member of the Swing package? Just trying to get lightweight versus heavyweight components sorted properly. Thanks. -- Curtis[/QUOTE] It's mostly, but not all, Swing. Here are the J's [url]http://java.sun.com/javase/6/docs/api/index-files/index-10.html[/url] Here's a non-Swing J: …

Member Avatar for verruckt24
0
89
Member Avatar for cassie_sanford

[QUOTE=cassie_sanford;802386]I have a title that is read in from the keyboard. I need to put it in quotation marks but i dont know how to do that...for instance, my program asks the user to put in a movie title and they input the title. Then i have to display the …

Member Avatar for Comatose
0
163
Member Avatar for guatemalagirl

Code tags and formatting please: [noparse] [code=JAVA] // paste code here [/code] [/noparse] [code=JAVA] import TerminalIO.KeyboardReader; public class LetterGradeWLT { public static void main (String [] args){ KeyboardReader reader = new KeyboardReader(); public boolean getLetterGrade(int grade){ grade = reader.readInt("Enter your numeric grade: "); int grade; if (grade >= 96) System.out.println(" …

Member Avatar for VernonDozier
0
100
Member Avatar for The Dude

[QUOTE=GrimJack;607920]If I remember the incident, you are correct the original poisoner was never caught Later someone poisoned their spouse with Excedrin but when no one caught on, she went out and laced another 5 bottles and someone else died. Then she collected on his accidental death policy. She was caught …

Member Avatar for GrimJack
0
183
Member Avatar for tedobg

How about changing this: [code] if (ch=='\b') cout<<'\b'<<' '<<'\b'; [/code] to this: [code] if (ch=='\b') { cout<<'\b'<<' '<<'\b'; Pass.resize (Pass.length () - 1); } [/code] You'd have to add code to make sure that you can't backspace on the empty string but it works otherwise as far as I have …

Member Avatar for trapkat20
-1
161
Member Avatar for redhotspike

[code] int Player::choose(int player) { int random_integer = rand(); if (random_integer%2) { cout << playerName << " goes first." << endl; } else { cout << playerName << " goes first." << endl; } } [/code] You don't return an integer, and you don't use the parameter passed to this …

Member Avatar for VernonDozier
0
3K
Member Avatar for ntredame

[QUOTE=ntredame;799113]Thanks so much for the input. When I use h3xc0de's solution I get an error. [code] 66: getNextDay(java.lang.String) in assignment5_3.Day cannot be applied to () d.setDay(d.getNextDay()); [/code] Any ideas? I would rather not use the array solution since I do not fully understand arrays yet.[/QUOTE] I don't know what line …

Member Avatar for h3xc0de
0
202
Member Avatar for rosenberg_a

[QUOTE=rosenberg_a;797136] [CODE] vector<int> vect = {13579, 26791, 26792, 33445, 55555, 62483, 77777, 79422, 85647, 93121}; } [/CODE] What i don't understand is how come the binary_search isn't recognized inside the function. If i need to pass something to the function then what? Also it possibe to make the function above …

Member Avatar for VernonDozier
0
137
Member Avatar for kishore84

[QUOTE=kishore84;794350]#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> int pick() { int arr[5]={2,3,4,5,6}; int random; srand(time(NULL)); random = arr[rand() % 5 ]; return random; } int main() { pick(); int i = 0; while(i<5) { printf("random number from the array %d\n",pick()); } getch(); } This is code i have written …

Member Avatar for VernonDozier
0
3K
Member Avatar for Ontonyx

[QUOTE=Ontonyx;797134]Ok, This program is designed to output sides and angles of a triangle based upon a side and angle that is inputted by the user. When I run the program the lenghts of the sides that I receive make absolutely no sense..but when I do them in my calculator they …

Member Avatar for VernonDozier
0
128
Member Avatar for Ontonyx

Is this the same problem as your other thread? If so, please close this one so people will know which thread to respond to. I just responded to your other thread.

Member Avatar for VernonDozier
0
102
Member Avatar for jdbarry

Your code is an ideal candidate for: 1) A class: You have a whole bunch of attributes which you are storing in separate arrays. Make a class and make a single array of that class. 2) A loop: You have a bunch of print statements where you display information, about …

Member Avatar for VernonDozier
0
152
Member Avatar for MyRedz

[QUOTE=MyRedz;796261] for decimal to binary not yet.. what's the formula again?[/QUOTE] The "formula" (more like a procedure) is described in niek's link. I assume you have read it and have a specific question? Read niek's link and others, try it out, and once you have tried it several times with …

Member Avatar for VernonDozier
0
99
Member Avatar for soroushc

[QUOTE=soroushc;795546]I don't know how to use vectors! [/QUOTE] Then learn how to use vectors: [url]http://www.dreamincode.net/forums/showtopic33631.htm[/url] [url]http://www.cplusplus.com/reference/stl/vector/[/url] [QUOTE=soroushc;795546] regarding using string!Strings doesn't work fine with this, because I don't know how many times the user will enter data![/QUOTE] That's why you use a vector. You may want to set up a …

Member Avatar for VernonDozier
0
111
Member Avatar for skitzo315

[QUOTE=skitzo315;794165]I'm new to C++ and I can't seem to find the problem with my code. I have a function that opens an input file. It asks you to input a file and if it can’t open the file it asks you if you want to try again. If you answer …

Member Avatar for VernonDozier
0
149
Member Avatar for CPPRULZ

[QUOTE=CPPRULZ;793198]Say I have a class (say number) and declare a private variable (say int num) and have a public member function(say int getnum() ) that retrieves the private variable. When I in the main() without initializing the private variable int num (of course after declaring the class variable say test) …

Member Avatar for VernonDozier
0
112
Member Avatar for daviddoria

[QUOTE=daviddoria;792015][code] double P = 3.5/(.1 * sqrt(2.0*3.14159)) * exp(-pow(5.0,2) / (2.0*pow(.1,2))); cout << P << endl; if (P==0) cout << "P is zero!" << endl; [/code] Is this underflowing so it is getting rounded to zero? The problem is that I am taking the log of this, so if it …

Member Avatar for Rashakil Fol
0
115
Member Avatar for daviddoria

[QUOTE=daviddoria;791990]So here's what I've got [code] void Pause(void) { char ch; while ( cin.get ( ch ) && ch != '\n' ); cin.get(); //pause the program } void TestPause() { cout << "hello" << endl; Pause(); cout << "goodbye" << endl; } [/code] It's pretty close... I have to hit …

Member Avatar for Nick Evan
0
150
Member Avatar for curtissumpter

Please use code tags and formatting: [noparse] [code=JAVA] // paste code here [/code] [/noparse] That's a lot of code. Can you point us to a particular spot in the code to focus on where you think the problem is?

Member Avatar for Ezzaral
0
997
Member Avatar for d4diaz

[QUOTE=d4diaz;791121]hey guys please help me out here.i really liked to know how to convert hexadecimal to binary[/QUOTE] Type "C++ hexadecimal to binary" into the Daniweb and/or Google search box and a lot will come up. That should give you at least a start. Then please post your attempt.

Member Avatar for Freaky_Chris
0
89

The End.