WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I see 6 functions. Based on both your threads, it's time to dust off the:

[boilerplate_help_info]
Posting requests for help must be well thought out if you want help quickly and correctly. Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful? Check your post with these checkpoints - what is it you missed:

  1. Ask a question that can be answered. Do not ask
    -What's wrong with my code?
    -Why doesn't this work?
    -Anything else that does not give us useful information.
  2. Post your code. If we don't know what you did, how can we possibly help?
    -Use PROPER FORMATTING -- see this
    -Use CODE Tags so your formatting is preserved.
    If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable.
  3. Explain what the code is supposed to do. If we don't know where the target is, how can we help you hit it?
  4. Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
  5. If you have errors, post them! We can't see your screen. We can't read your mind. You need to tell us what happened.
  6. Do not ask for code. We are not a coding service. …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Many of us ignore any posts with URGENT or ASAP. They indicate to us posters that think their problems are more wothy of help than others, and, to us, there is no urgency at all.

But aside from that (don't do it again) you need to ask better questions. You ask:

I was supposed to do a function for line 9:

The function shall take two input arguments:
the line 7 amount and the line 8 amount.
o The function will test if line 7 is equal to or more than line 8, and then compute
the correct results for line 9.

Well, line 9 is const double CUTOFF1 = 10000;. There is no possible way to convert that into a function.

Remember, we don't know your project so you must explain what you really need in terms of the code you have, not the unspecified project directions

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look you the is***() functions -- isalpha() isdigit() ispunct() etc...

They are in the ctype (or ctypes, I can never remember) header

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In re WaltP's post; The reason I took this approach was because the chapter of "Accelerated C++" was all about iterators and seemed to want me to go down this path.

OK. That makes sense.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Reread what JorgeM said.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Consider giving your users options if they want to disable the feature or not.

Agreed. And if disabled, add a button to share so they still can. And stop apologizing. There's nothing worse that someone always apologizing for something they do over and over and over anyway ;o)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

for(string::const_iterator iter = s.begin(); iter != s.end(); ++iter)What does this line do?

string::const_reverse_iterator rit = s.rbegin();
What does this line do?

What do the variables defined (iter, rit) point to or indicate.

Why make pointer to the characters? Why not generate subscripts and just use them?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In your original description you said

Given number n ( n<=9999)

Inputting a string is not a number. You need to rethink your program and reconsider this suggestion.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well, you could post there and just see how good or bad it really is. Consider it a live test of your thoery that it needs to be split and show the DW designers that the current design is flawed.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Dani: Not just India. That's what I was taught to use too!

How long ago was that?

nitin1 commented: nice question ;) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So, Please make it more active and please reply on my post over there now to start from now only ;)

So please, if you want it more active, post there. We aren't going to hire people just to post there so it can be more active for you. When you post there, it will become more active ay at least one more post.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Mike, he said:

The purpose is to create a brand new object each time the loop is executed for as long as the loop runs.

so he wants

while(/* .. some condition .. */) {
  // ... some code..
  create a DataType Obj;  // another object 'Obj' gets created here.
  // .. .some more code..
}; 
delete all objects

so if the loop runs 6 times, 6 objects get created. 20 times, 20 objects.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need the header cstring for the C style function. string is for the C++ string object.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Bubble sort is really bad performer and implementing insertion or selection sort instead is not any harder. Best is of course to use the sort from algorithm instead of reinventing the wheel.

5 values. The worst sort in the world is more than adequate for 5 values.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you have the numbers 3,5,9,2,6,5,1, what is the very first thing you do to see if there are duplicates?
Check the 3 & 5, right?
What's next? 3 & 9.
Next, 3 & 2.
Get the pattern?

When done with th 3, what do you do?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It's only 7 integers, so sorting is an extra added complexity. It is a good way, but if you can't find duplicates, you'll get lost in the sort.

Write down 7 numbers randomly on a piece of paper -- making sure to have one duplicate.

Now, looking at 2 numbers at a time, what steps will you go through to check for duplicates? Write those steps down. Now you have a preliminary 'program' you can translate into code.

Hint: Think two loops, nested (one inside the other).

-------------

Come to think of it, the pattern (algorithm, pseudocode) is very much like a sort. You just don't move the values around.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Bob: you'll need to sort the values yourself and find the largest.

Bob: A simple (though relatively inefficient) sorting routine is the bubblesort, so if you search for examples, that would get you started.

iamthwee: You will need a loop

iamthwee: Then you will need to use the less than or greater than operator to compare the values
MandrewP: Yes, I would do a bubblesort.

Seems to me you've already been given the information you need. Or do you want us to do the research and write it for you?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look more closely at ("test\" (variable+".txt").c_str() ).
You are missing something.

It's usually better to create complex strings in pieces rather than all in one line like this. Once you get the string generated properly, then start combining the terms.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Of course it's giving the same seed. time(0) returns the current second. So, unless each call to srand() if over 1 second apart, the seeds are identical, giving identical random values.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please use consisent formatting so we can read the code easier...

return (sales1, sales2, sales3, sales4);
Illegal format. Look up the return statement again...

... but it does not do the calculation and display the output

Meaning what? Nothing gets output? Bad information? Crashes? When asking for help ALWAYS
1) explain what happened
2) what you expected instead
3) the input
4) and anything else you need us to know about the program because YOU wrote it, WE didn't.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I was always for this particular solution.

I do find, though, that "Deleted Member" is a bit offputting. Any way we can keep the name on each post but with that small font, and change the poster level to "Deleted Member"? I've seen that format used to good effect and still accomplishes the request.

happygeek commented: seconded! +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't see int getSSN(){return SSN;} anywhere in that code. What line number?

Did problem #2 make any sense to you?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Execution starts from main(), are you allowed to include main() as a member function of a class ? May be I'm wrong.

No you are not. main() cannot be part of the class. It must stand alone.

And void main() is wrong. It's int main() -- and always has been. Before you start arguing, it doesn't matter that your instructor taught you it's void, he is wrong. Period. See this.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why are we allowed to delete memberships now?

nitin1 commented: nice question :) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) I said use isspace(), not write it. You use it in a function called (for example) skipSpaces() or spanSpace() as I called it originally.

I'll give you a start:

int spanSpace(char *str, int idx)
{
    while (isspace(str[idx]))  // as long as current character is a space...
        idx++;                 // skip it.
    return idx;                // return the new index, poins to a non-space
}

Now research isspace() and the others to see how they are used.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

cin >> studentList[row].getSSN();

I don't see any definition at all for getSSN(). I suspect that's problem 1.
Problem 2 is probably because getSSN() returns a value (as suggested by the name) and you are trying to read into it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Problem #1: you claim you're struggling with this code.
Problem #2: you give no indication what the struggle is
Problem #3: we are not psychic so have no idea what the struggle is
Solution#1: read the post at the top of the forum titled "Read This Before Posting A Question"
Solution#2: post again

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Use a loop to calculate successive values of the functions.
Use those values to place a point in your output.
As for magic++, I've never used it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Did you actually look up the erase and remove methods of the string class? I'll bet their description would help you determine how and why and which to use.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

:o) means I'm kidding.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

NathanOliver: And what seems to be the problem? It is asking a lot to give us 600 lines of code and not say what problem you are having with it.

poloblue: I'm problems with the studentType header file in this function:

Did you miss the part of NathanOliver's post that said "... and not say what problem you are having with it"?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

We really can't get hung up on pos/neg votes. Over the past month I've been downvoted for

1) reversing my stance and stating I now understand a situation and agree with the decision here
2) answering questions that help the user here
3) explaining the details of a problem and showing exactly why it happens and how to understand it here
4) never having programmed a downloader task because of lack of interest here
5) Asking for clarification here
(none of which the voter was brave enough to leave a name/message - the cowards ;)

Of course some others were well deserved.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I was actually happier not knowing about them :o)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

But your avatar is FAR from hippy... Closer to Fury ;o)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Contact HP.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Read the quote again: "during compilation sizeof expressions get replaced by constant". Just like a #define. Just like a macro.

Don't get hung up on preprocessing and compile. It doesn't matter. You just can't use it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Consider sizeof to be similar to #define. It is created during compile, not while running.

From http://en.wikipedia.org/wiki/Sizeof#Implementation
"In most cases, sizeof is a compile-time operator, which means that during compilation sizeof expressions get replaced by constant result-values."

So you can't write one. You can only write run-time code.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
int main()
{
    double n;
    cout << "Please enter a number: ";
    cin >> n;

    printOut(n);

Isn't it already a double?

-----------------

double printOut(int n)
{

// what's the value of N right here?
if ( n < 0 )

See the comment

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In printOut(), is the value of n accurate? Better check...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Then we obviously need more context. Like the function(s) that call this one, the one that opens the file, and the first few lines of the file.

And an exact descripton of what's going wrong with as much detail as you can provide.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can someone tell me why i get the error code "ISO C++ forbids comparison between pointer and integer" for lines 135 and 149

135 is for( int i = 0; index < 12; i++)
149 is for( int i = 0; index < 12; i++)

You need to make sure the line numbers match so we can look at the correct code.

Whaterver is on line 135 and 149, you are comparing an integer with a pointer, just as the message says. Did you forget to dereference the pointer?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do you know about functions? Assuming you do, I see some that would be very helpful:

1) int spanSpaces(line, index)
This will start at line[index], skip all 'whitespace' (look up the function isspace()) and return the index of the next non-space character.

2) int spanText(line, index)
Same, but skips all text values, for Label and Instruction. Are numbers allowed in the abel or Instruction? If so, isalnum() is the function to use, otherwise isalpha()

3) int spanNumber(line, index)
Again, same but skips numbers (isdigit())

Using theis idea, starting before INSTRUCTION you might do:

if current character (line[index]) is a space, 
    call spanSpace()
    store index in instBegin
    call spanText() with instBegin
    store index in instEnd
    copy the characters from instBegin to instEnd-1 into the instruction
If current character (line[index]) is a space, 
    call spanSpace()
    store index in numBegin
    ...

Just string the calls with appropriate tests before/after each call. You know what characters to expect after each field. Make sure they are there.

Of course you have to start with LABEL

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And what happens when you input EXACTLY the same input?

----

this is like pulling teeth

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And you still are.

The questions, one at a time:

What actually is displayed? (actual text)

Yes, you finally showed what was displayed.

And what's wrong with this?

I still don't really know, I have to guess.

What do you want displayed? (actual text, variable names, etc)

Don't see anything that shows what should have been displayed so I can't compare what your program should show vs what it did show.

Still don't know what variables you wanted to display -- again, I have to guess.

-------------

When answering questions, read each question one at a time and ask yourself "did I answer that question so they have the answer they asked for?"

Based on the input, you know what the output should be. We don't. So show us.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I repeat

What actually is displayed? (actual text) And what's wrong with this?
What do you want displayed? (actual text, variable names, etc)
Examples help greatly.

Was I unclear?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In normal syntax, optional values are surrounded with [ ], required are not. And, for this discussion, # will designate one or more SPACEs/TABs.
What I understand then is you can have the following:

[Label] # Instruction # number1,number2 # [; comment]

So:
A label cannot be preceeded by # and is optional

An instruction must be
1) preceeded by at least one #
2) followed by at least one # and number1

Both numbers are required in the format number1 comma number2 (are spaces allowed?)

The comment is completely optional.

If this is not correct (there are other optional parts), please update using the above syntax.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What is wrong? Please give details.

What actually is displayed? (actual text) And what's wrong with this?
What do you want displayed? (actual text, variable names, etc)
Examples help greatly.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I really don't have any links. If you use the above, it's just a matter of reading a line, checking the 1st character and compiling the data to make the change. When all the data has been read, the change can be made or an error displayed if there i missing data.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Store them in a file that the program will read.
Use a code that tells you what the file entry is, like

Ffilename.ext
RregistryKey
Vvalue
Etc...
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Instead of

for ( int i = 0; i <= NumUsed; i++ )
{
    for ( int j = 0; j <= NumUsed; j++ )
    {
        cout << List[i][j];
    }
}    

try

for ( int i = 0; i <= NumUsed; i++ )
{
        cout << List[i];
}