NathanOliver 429 Veteran Poster Featured Poster

program does not work:

Can you alaborate a little more than that?

Your fist for loop needs to have its statements wrapped in brackets since there are multiple lines.

for(int i = 0; i < 7; i++)
{
    //code here
    //code here
}

You are never multiplying the total by the difficulty.

NathanOliver 429 Veteran Poster Featured Poster

What do you have so far?

NathanOliver 429 Veteran Poster Featured Poster

Well you can take the number in as a string and make sure that there is only 1's and 0's in it.

NathanOliver 429 Veteran Poster Featured Poster

Change line 11 to

if (std::string::npos == (pos = temp.find("x^2"))) 
NathanOliver 429 Veteran Poster Featured Poster

how does the >> operator work for your Polynomial class? I ask because if you use getline inside the Polynomial class then cin >> will be throwing you off. What happens if you put cin.get() between lines 34 and 35?

NathanOliver 429 Veteran Poster Featured Poster

So you need to find some group of 3 items that has the same type and the highest sum of thier values? If that is the case then I would split you main array into seperate arrays for each type. Then sort those arrays in descending order. Then find which array has the highest sum for the first three elements.

NathanOliver 429 Veteran Poster Featured Poster

Want to post the code you have?

NathanOliver 429 Veteran Poster Featured Poster

Not with that amount of information. What are you trying to do? Is this a code problem? I know a picture is worth a thousand words but I think the words would do a better job of explaing what you are trying to do.

NathanOliver 429 Veteran Poster Featured Poster

So what do you have so far? Do you know how to use a string? The find_first_not_of() function can be really helpful.

NathanOliver 429 Veteran Poster Featured Poster

It would be better to post the code that you are having trouble with on the site so other people can learn as well. Post the part of the code that is giving you the issue plus anything relevent that it relies on.

NathanOliver 429 Veteran Poster Featured Poster

Yes. You need to figure out the size that you need o to be and then you use that size to allocate the memory you need with new.

NathanOliver 429 Veteran Poster Featured Poster

On line 4 you declare o as int *o=new int;. This ony gives you a single int pointer. So when you call line 16 you invalidate the pointer because you step out of the memory allocated to it. It looks to me like you need o to be an array. if you know what the size of o should be than make line 4 int *o=new int[size];, where size is the size of the array you need o to be. You are also incrementing c on line 17 but you never set c before you do that. You always want to set the value of a variable before you start using it.

NathanOliver 429 Veteran Poster Featured Poster

So what do you have so far?

NathanOliver 429 Veteran Poster Featured Poster

Um? You resurected a 4 year old thread about C++ to post Java code?

NathanOliver 429 Veteran Poster Featured Poster

What do you mean by abort? Does it exit immediately and you don’t see any output or do you get an error? it could be that the program is terminating to quickly. If so after lines 12 and 14 add cin.get() and see what happenes.

NathanOliver 429 Veteran Poster Featured Poster

This is sudo code but you shoud be able to get it to work

for index = startIndex to index = endIndex
    print array[index]
NathanOliver 429 Veteran Poster Featured Poster

Look at line 5. Does that match line 13 and 16?

NathanOliver 429 Veteran Poster Featured Poster

floor() rounds down to the nearest integer.

NathanOliver 429 Veteran Poster Featured Poster

you also still need to increment numGames when you call displayWinner()

NathanOliver 429 Veteran Poster Featured Poster

You are not passing any variables to your functions. Since you want to update what the values of the variables are you need to pass them by reference. You also need to get rid of the declerations of win, lose and tie in your functions. displayWinner() should look like this

void displayWinner(int & win, int & lose, int & tie)
{
    int compChoice, userChoice;  // do not declare win, lose and tie since they are function arguments
    // rest of your code here
}

and on line 131 you would call it like this

displayWinner(win, lose, tie);

Line 99 should be

void displayEnd(int win, int lose, int tie, int numGames)
{
    // rest of your code here
}

and on line 135 call displayEnd() like this

displayEnd(win, lose, tie, numGames);

You also need to increment numGames every time you call displayWinner(). Using goto is a big nono as well. anything thay you use a goto for can be replaced with a while loop. I might have missed a couple of things but make the changes I suggested and see what you get.

NathanOliver 429 Veteran Poster Featured Poster

I like your description of java rubberman. I fell the same way.

NathanOliver 429 Veteran Poster Featured Poster

What all is in word? is it just one word or a sentence. I ask because I dont know of a word that is 40 letters long outside of chemical compounds. How do you want to split the word? If the word puts you over 40 charecters do you split it or do you put the whole word on a new line.

NathanOliver 429 Veteran Poster Featured Poster

line 49 needs to be:

temp = temp + (data[i] * x.data[i]);

If you are mulitplying each vector element agianst the other. One issue I see is how are you going to handle mismatched vector sizes?

NathanOliver 429 Veteran Poster Featured Poster

stoi() is overloaded to take a string or a wstring.

NathanOliver 429 Veteran Poster Featured Poster

Well you can use strstr() from the cstring library. That will work with char arrays.

NathanOliver 429 Veteran Poster Featured Poster

Well if you can use the string classs the you can use the find() method to look for the word include. Then parse from there to make sure it is correct.

NathanOliver 429 Veteran Poster Featured Poster

That is some pretty bad to code to resurrect a 5 year old thread with.

NathanOliver 429 Veteran Poster Featured Poster

You might have to add the directory where the .h file is into the linker so it will search for it. What is the exact error yu are getting?

NathanOliver 429 Veteran Poster Featured Poster

Where are the swt() and iswt() functions declared/defined? Are they in the wavelet2d.h header file?

NathanOliver 429 Veteran Poster Featured Poster

Schol-R-LEA haven't you ever seen Ghostbusters?

Gozer: Are you a god?
Ray Stantz: [looks at Venkman, who nods] No.
Gozer: Then... DIIIIIIIIE! [sends the Ghostbusters sprawling with lightning bolts]
Winston Zeddmore: Ray, when someone asks you if you're a god, you say "Yes!"

NathanOliver 429 Veteran Poster Featured Poster

What are the error messages you are getting?

Moschops commented: Needs saying so often. Well done. +8
NathanOliver 429 Veteran Poster Featured Poster

Where is the text file? If it is not the same location where you .cpp file is then you need to put the exact path to where the file is.

NathanOliver 429 Veteran Poster Featured Poster

what does the actual contents of the file look like?

NathanOliver 429 Veteran Poster Featured Poster

Use this as an example:
base class

//base.h
#ifndef BASE_H
#define BASE_H

class Base
{
    int foo;

public:
    Base(int number) : foo(number) {}
};

#endif

derived class

//derived.h
#ifndef DERIVED_H  //<- inclusion gaurding
#define DERIVED_H

#include "base.h"  //<- this adds the code from base.h to derived.h

class Derived : public Base
{
    int foobar;
public:
    Derived(int num1, int num2) : Base(num1), foobar(num2) {}
};

#endif

This is how your headers would look. Then in the .cpp files you would just need to include the .h that the .cpp file is named after.

base class .cpp file

//base.cpp
#include "base.h"

// all the code for the base class would go here

derived class .cpp file

//derived.cpp
#include "derived.cpp"

// all the code for the derived class would go here.
NathanOliver 429 Veteran Poster Featured Poster

You dont have to have it in your .h file for your derived class but you do need to included it in you .h file.

NathanOliver 429 Veteran Poster Featured Poster

MSVC++ is mostly standard compliant. I say mostly because it doesnt have all of the C++11 features. It's C++98/03 compliance is pretty good.

NathanOliver 429 Veteran Poster Featured Poster

line 76 should be

b = abcd[1];

not

abcd[1]=b

Also the use of goto is a big no no for c++. With the loop options availible you should never need to use one. You also need to learn how to indent properly.

aVar++ commented: Indentation is very important. +2
NathanOliver 429 Veteran Poster Featured Poster

No. You need to create a stack that uses a linked list for its data structure. You also need to indent you code correctly. If you look at the first post in your linked list thread the way the code is formatted there is how you should format your code when you post. I personally won’t read code that has no indentation.

NathanOliver 429 Veteran Poster Featured Poster

No. It says you have to implement this with a linked list.

NathanOliver 429 Veteran Poster Featured Poster

What is the code that you have? You need to search through the array and find a row that has enough open seats that are together.

NathanOliver 429 Veteran Poster Featured Poster

Firstly you are not using a vector but an array. You need to have the array in main and pass it to the function that takes in input and then pass it to the average function.

NathanOliver 429 Veteran Poster Featured Poster

Check out the win32 API.

NathanOliver 429 Veteran Poster Featured Poster

I would go the polymorphism route. That way if you need to add another standard latter on all you have to do is create a new derived class and add the option for the new standard.

NathanOliver 429 Veteran Poster Featured Poster

So what do you have so far?

NathanOliver 429 Veteran Poster Featured Poster

The >> operator leaves the newline in the buffer. You need to get rid of that before you can use getline() since getline() stops reading once it sees a newline. Check out this guide that Narue created. It should tell you how to fix your problem.

NathanOliver 429 Veteran Poster Featured Poster

Line 9 of you code is

double rightTriangle(double x, double y)

Line 25 of your code is

double rightTrangle(double x, double y)

Notice anything different? I'll give you a hint. Look at the name of the function.

NathanOliver 429 Veteran Poster Featured Poster

What do you have so far?

Create the logic for a program that prompts a user for three
numbers and stores them in an array.

You need an array of size 3 and a for loop to do this

Pass the array to a method that reverses the order of the numbers.

You will need to write a function that takes the array as parameters for this. Then in the function you need to swap the first and last element to reverse it since it is only 3 elements.

Display the reversed numbers in the main program

Again you will need a for loop to go through the array and print out the elements.

NathanOliver 429 Veteran Poster Featured Poster

The problem you are getting is that you are mixing your input types. Using the >> operator leaves the newline in the stream. When you call getline after that it reads in the newline and then stops. That is how getline works. It will keep reading untill it sees a newline.

NathanOliver 429 Veteran Poster Featured Poster

If you are mixing the >> operator and getline you need to use ignore() before calling getline. Give this a try

cin.ignore();  <-- added this
cout << "Enter the company name: ";
getline(cin, company_name);
NathanOliver 429 Veteran Poster Featured Poster

Line 24 needs to be nodeType* head_ptr;. That should fix some of the errors.