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

Less is more :)

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

See if there is a function called clock()

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

I don't believe this code compiled. There is no DisplayList()

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

It would also be nice if you'd look at the code posted on the forum and reformat it for your next post so we can follow what is happening. Pretty code is much easier to read.

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

As Jonsca said, TFA=$10,000 is not a valid statement. It needs to be TFA=10000 since $ and , are not valid digits.

And the computer has no idea what NHT=2% OF MONTHLY GROSS means. You need to calculate the value of monthly gross in some variable (maybe MonthlyGross ) then set NHT to 2% of it: NHT = MonthlyGross * 0.02; 2% is meaningless also, by the way. It's 0.02.

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

As you obviously know, you divide out the last 3 digits and call the function again.

When you divide out the digits and your source is 0, you have the highest value as a result (the 45 from 45,652,567)
Output it and return.

The return loop then outputs ',' followed by the precious result.

So a minor change to you function should get it. Think if-else when you get your result.

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

OK, I see the function.

If you want to return the player, why is it a void function? Let it return the player:

int getplayer(int thisplayer) 
{
    if (thisplayer == 0) 
    {
        thisplayer = 1;
    }
    else
    {
        thisplayer = 0;
    }
    return thisplayer;
}

Now you have either player 0 or player 1.

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

Here, since someone gave me a warning for "unorganized post" Ill made it easier to understand for such people.

If you bothered to read the warning it has nothing to do with the content of your post. Read it again if you are confused.

As for you endless loop problem my comments above still stand. There is no "remembering" in the program once the loop starts again. What it knew in the first loop is forgotten in the second loop.

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

What do you do now to change from player 0 to player 1? I see no attempt to switch.

All your winner function does is look for a winner. It doesn't return who the winner is. If that's enough, OK. Otherwise, you might want to think about it a little more. Also, if your first loop finds a winner is it necessary to go through all the other loops?

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

i need to make a program that reads in a file and list things like
the number of characters,words lines spaces tabs etc.
anyone know the best way to do this?
any help anyone can provide is appreciated

thanks

Make a list what you need to keep track of.
Add to each of these items what indicates the item -- meaning if you need to count words, what indicates the end of a word?

There is never a best way. There are hundreds of ways to do any program. Keep in mind the word best rarely if ever really exists in computers.

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

Hi:

Thanks for ur reply.

Are you saying that i should use feof instead of eof ? I am not sure.

If they are identical, what do you think? You need to look in your text how to loop through a file.

The other thing is I am not sure what I can do about that getchar. I am positive that what I have in my code is wrong. All I am able to see is that if there is a space, i should increment the counter by 1.

Good, you know there is a problem. That's better than some others I've seen.
You need to think about what you are attempting to do. What designates the end of a word? What indicates the end of a line? Maybe in your loop instead of reading each line you could read each character looking for and counting these indicators.

See what you can do with that idea.

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

I mean seriously! Could you quote the passages in your book that states these are valic C++ statements:

TFA=$10,000
NIS=$520 OR $1040
NHT=2% OF MONTHLY GROSS
PEN=5% OF MONTHLY GROSS
EDTX=2% OF (GMS-NIS-PEN)
INTX=25% OF (GMS-PEN-NIS-TFA)
Bonus1=$15000
Bonus2=$9000
Bonus3=$3000
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK. I did it. Now what?

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

You should not be doing while (!myfile.eof()) -- here's why (feof() and .eof() are identical)

After you've read all the lines in the loop, what do you expect getchar() to read?

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

Look at your parameters. What does the function require? What are the actual definitions of the variables?

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

Here are the instructions

Goodbye Screen (screen 7)
display goodbye message, wait 10 seconds, cycle back to welcome screen

Very good. I repeat:

What function are you calling to actually perform the wait?

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

Because if mazeArray[readRow][readColumn] is north you go up one row.
Then if the new mazeArray[readRow][readColumn] is south, you go down one row.
now the new mazeArray[readRow][readColumn] is north (we know this because you were just there) you go up one row.
Then....

You need to keep track of which directions you've already gone so you don't get stuck like this.

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

I think you are just 'moving too fast'. Study the documentation, for example fopen_s().

Actually, for all the *_s functions -- stop using them. They are not standard which makes it very difficult to help you, and will make it difficult to write code if you need to use a different compiler.

And post the EXACT error messages, not a paraphrase. It helps us to see exactly what the compiler says.

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

"C INPUT FUNCTIONS" brings up sites with help on input functions in C.

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

What function are you calling to actually perform the wait? All I see is math done on the value to wait.

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

You always output the 3 digits followed by ','. Assume you have 10. Follow the code with that value to see why the comma is output.

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

thank you!

thread solved

Then why didn't you mark it solved?

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

Paramount -> Indiana Jones

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

Bumps don't count

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

ding

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

Instructor being 'C++ For Dummies'.
:$

:icon_razz: plbbbbbbb..


:)

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

Useful tips:

you can consolidate lines 13 through 33, and eliminate lines 37 through 44 by doing this:
---
Furthermore, keeping your choices in array format would simplify your code:

Assuming he's learned arrays. If not, instructor may not like it...

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

Yeah, figured you had a brain fart and could correct it easily... :icon_wink:

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

Why? This thread has been dead for months. We could have given you an infraction instead for resurrecting a dead thread and for giving an answer to someone's homework question -- IOW cheating. Consider yourself lucky.

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

That's because each line you mentioned is extremely wrong.
Look up do-while loop to understand the syntax of the statement.

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

You don't. Unless your computer can read your mind, you need to type your question. I just happen to know high-level tricks.

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

How can you not find information on CODE TAGS
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) any place CODE tags were used, even in responses to your posts
5) Even on the background of the box you actually typed your message in!

kvprajapati commented: nice reference for me, sir. +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Have you learned anything about converting numbers to strings? Any string manipulation at all? If not, you do not have the knowledge yet. Give it a couple weeks and return to this question. You should have the concepts by then.

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

Nice try. Homework questions are generally not designed to be tricky. They are designed to teach. Narue is correct.

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

The Member Rules state "Do not post threads with generic subjects such as "HELP ME" or "PROBLEM". Instead, clearly state a phrase describing the problem as the thread's title." Please post proper titles next time.
Also, we aren't psychic. How can we possibly figure out what help you need with given the information you provided. Please read the required posts and rules.

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

Thank you for using code tags, but The Member Rules state "Do not post threads with generic subjects such as "HELP ME" or "PROBLEM". Instead, clearly state a phrase describing the problem as the thread's title." Please post proper titles next time.

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

Look up "tree traversal"

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

You don't know how to use Google? The link I posted will teach you.

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

We need to send one to Graham Norton!

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

Sure. See this and specifically this

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

Why not? Just print '|'.

#include <iostream>
using namespace std;

int main()
{
    cout << "||||||||||" << endl;
    
    return 0;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Did you get the correct answers?

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

It just means somewhere you defined a variable p and didn't use it in the code.

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

The problem asked how to print vertical lines "|".I was also working on the same problem and was getting the same doubt and then I saw someone has already posted the doubt but no one has replied to it.

No, the problem is "My assingment is C++ program to insert and delete elements in Binary Search Tree.I am almost done wid the assingment. But the major part lies here. the strucure of the output is difficult to obtain.. i will explzin the question now."

Are you attempting to hijack this thread for your own question? Don't. Start your own thread. This is gajji2020's thread.

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

Could anyone please help on how to print "|" here....

What does this question have to do with the problem posted?

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

Maybe this will help more tan the other link

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

Looks to me like you need to explain in detail what the problems are -- and where in the code you're having problems. I don't see a problem in compShip() which it sounds like you're complaining about.

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

When would you like it? How complex should we make it? Can you teach us what a music cutter is? How do we read the music? Convert from what to what?

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

Why did you calculate temp? You just threw it away.

You might be better off getting the input into temp variables.

After reading one fruit, look through the array and
-- if the fruit is not there, put the values into the array
-- if the fruit is there, add the number to the the fruit number.
Then get the next fruit.

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

Maybe it might be a good idea to look up switch in your book. Books generally explain these things.