2,827 Posted Topics
Re: 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( … | |
Re: [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 … | |
Re: [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 … | |
Re: [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 … | |
Re: What input did you give it, what was the actual output, and what should have been the output? | |
Re: 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? | |
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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … | |
Re: 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] | |
Re: 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 … | |
Re: [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: | |
Re: 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? | |
Re: [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 … | |
Re: [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, … ![]() | |
Re: 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] | |
Re: 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 … | |
Re: 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 ( … | |
Re: [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 … | |
Re: [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 … | |
Re: 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] … | |
Re: [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 … | |
Re: [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 … | |
Re: 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. | |
Re: [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 … | |
Re: 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, … | |
Re: 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 … | |
Re: 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". | |
Re: [code] while (row++ > 0) cout<<"*"; [/code] If you ever get into this while-loop, will you ever get out of it? | |
Re: [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: … | |
Re: [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 … | |
Re: 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(" … | |
Re: [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 … | |
Re: 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 … | |
Re: [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 … | |
Re: [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 … | |
Re: [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 … | |
Re: [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 … | |
Re: [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 … | |
Re: 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. | |
Re: 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 … | |
Re: [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 … | |
Re: [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 … | |
Re: [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 … | |
Re: [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) … | |
Re: [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 … | |
Re: [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 … | |
Re: 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? | |
Re: [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. |
The End.