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

We cannot copy and quote posts that contain tagged code without removing all indentation. Makes quoting code useless and difficult, unless there is a user friendly way we should know via mental osmosis that has not yet been documented.

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

The error kicks the user out of the program so it shouldn't display any results.

OK, I get it now... Wouldn't it be better to ask for the input again rather than waste all the previous inputs?

I think I could either subtract each denomination as many times as i can as long as it doesn't go below 0. This could probably be made into a for loop.

Or maybe I could somehow use a Token? I'm not too familiar with making a class.

Modify your program to ask for an integer dollar amount and make
change.

Or,

as long as the current total is > than the denomination
    add 1 to count
    subtract denomination from total

next denomination

By the way, if you are going to output the quantity immediately, there is no need for the array. Just sayin'.

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

Yes, what you just claimed is correct. Nevertheless, the function doesn't do what you claim it does. Please show me the exact statement(s) that are used to

see if the user inputed a lab number thats in the array.

How is it actually testing the lab number and what is it testing with? In order to see something you have to look at something.

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

No. They are just a different way of doing it. And you'd still need a loop anyway. IMO, your technique is just fine without the class. Although, if you notice, every one of your input sections look exactly the same:

cout << "Enter the number of XXX Dollar Bills you have: ";
cin >> bill;
cout << '\n';
bills.push_back(bill);
if (bill<0)
    error("You can't have a negative value.\n");

except for the XXX value. You could use a single loop with the XXX values in an array.

Also note that if you enter a negative number, you
1) display an error message but do not ask for a valid value
2) store and use the negative number anyway

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

but that function is not really supposed to do anything. All it does is go through the array and see if the user inputed a lab number thats in the array.

But it doesn't "see if the user inputed a lab number thats in the array". All it does it add 1 to the values I mentioned then exits. It never checks the array for any values at all.

In other word, if I want to check if my array list has the value 20 in it, testing using your technique I'd have:

i = 0;
while (i < TotalValues)
{
    i++;
}

Where is the test for 20? Or in your case, the Lab number?

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

As nmaillet implies, your loop should be only around your password test, not the entire program.

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

This functin is designed to go through the rows that I've allocated in my dynamic array and see if it the user inputed a valid lab number.

It doesn't do anything. All the function does is increment a pointer and the steps.

And if (*rowWalker == NULL) is TRUE you don't actually return anything. A value is only returned when if (*rowWalker == NULL) is FALSE.

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

It wouldn't help. It's what you already have.

First things first. Fix these variables: int a, b, c, d, e, f, g, h, i, j, k;
They mean absolutely nothing and only serve to confuse anyone reading the code.

The function RepeatedlyCoins (int ¢s, int coin_worth) will return the number of coins but you never remove those coins from the the total number of cents. If you do, I don't see it.

Put some output statements in key places in the code to see if you are processing the values correctly.

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

format your code better. It very difficult to follow.

How do I link the names inputed together with the height and width???

Well, if you need to swap the name[i] with name[j], what else do you need to do?

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

please write this code for me!! Im in dire need!!

Why do you people continually ask us to do your work for you? This constant request for cheating is really getting annoying!

Find something else to do.

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

can you keep it like a computer science I beginner level with the same functions and variables as i had up top

So what you want is to for him rewrite your homework for you so it looks like you wrote it, not an expert?

Wouldn't it be better if you actually wrote it, being guided by help so you'd actually learn to do it?

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

Why don't you try using FireFox. Its fast and sleek.

Patient: "Doctor, it hurts when I blink."
Doctor: "Don't blink."

Isn't it more like:

Person A: My car needs a brake job.
Person B: Why don't you get a new car?

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

Line 38 you probably want diff_w and suitor_w

Sort on the value you want (diff_w or diff_h). Make sure you swap all the arrays. Then output your data for that sort.

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

You need to break up your loop into multiple loops.

1st) read the entire file in one loop
2nd) sort the data using two loops
3rd) the rest of the program

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

Introducing a flag with additional code to set and check it seems like a poor solution, especially when it's not needed. Doesn't simply moving the printing instruction out of the loop do what you describe?

You're right, IF it's not needed. But that all depends on if the following output is acceptable:

line
line
line
########   'run #2
line
line
line
########   'run #3
########   'run #4
########   'run #5
line
line
########   'run #6
########   'run #7
########   'run #8
########   'run #9
line
line
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
/* This function is used to calculate how many of each coin is needed */
int RepeatedlyCoins (int ¢s, int coin_worth)
{

What is the first parameter in this function definition? Never seen a variable like that.

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

Either
1) print the ##### before you start the while loop
2) set a flag named FirstLineFlag to true before you enter the loop and set it to false after you print. You can work out the rest of the details.

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

If you aren't sure how find works, you should forget all the other parts of the program for the moment and just program various uses of find until you understand how that works. That will make programming the rest of the task easier.

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

Each peg is an array.
Load peg 1 with the disks

peg[0] = 1
peg[1] = 2
etc

Each time you move a disk you must take the last value in the array and place it in the first open location in the new array/peg

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

Please explain exactly how you are checking for a prime. I see no code at all that does it.

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

You were told here about void main(), conio.h

You were told here about conio.h, void main(), putting non-code into your code to confuse us.

You were told here and here about void main()

And here about using goto

here again void main() was mentioned.

And I know goto, conio.h, formatting your code, and not proofreading your post has been mentioned before.

Question -- if you refuse to listen, why should we help you?
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Because if you deleted the post, wouldn't all the replies look a little stupid? ;-)

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

If this is for a class, I would suggest you think of something that would use the skills you've learned in class rather than trying to do something that will take a few months just to learn the basics of techniques you've never touched.

Look at something like Mastermind, Tic Tac Toe, Craps, Hangman. Something that won't take years to design and implement.

The key is design!!! Don't just sit an the computer and start programming. Sit as a desk and figure out how the game is supposed to work and figure out all the details of input, the play, the decisions, the output -- everything to make the game work. Once you figure all that out, it'll be fast and easy to actually write the code...

So don't touch the computer until you've figured out everything you need to do.

myk45 commented: very good points +5
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Possible, of course. Doable with your current knowledge of C, the compiler, graphics, etc, only you can decide.

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

But you aren NOT new to asking questions. You KNOW when you ask questions you must give an explanation of the problem, not just tell us to fix it.

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

whats wrong with it?

See this

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

And what happens?

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

Yes we can, but we can't read it because of the lack of formatting.

See this
See this too
Do not use goto's and get rid of the label's

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

1) void main() is wrong. See this
2) conio.h is non-standard. You do not need it.
3) format your code properly.

i'm thinking of using an array...the code ive done would read the first line right?

Right.

but i want to read as an array if it would be possible..

It's completely possible.

I got an error when trying it.

trying what? Reading into an array? Since you don't have any arrays and you are reading only one line, you can't have an error reading an array. So we can't help you figure out what you did wrong.

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

Output the values you use in the loop and see what they generate.
When you see that the values are wrong, you then know what to look for to fix the problem.

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

Line 26. Your program can't compile with that line in it.

And if that's supposed to be a question, after 200+ posts you'd think you'd know better than to simply say "it doesn't work" and let us try to figure out what that means.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
nitin1 commented: walt will always be walt ;) he can never change :-D +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your code won't compile with that extra meaningless text at bottom of the program.

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

Reverend Jim: So do I have it straight now?

Simply clicking up-vote or down-vote affects only the number displayed between the arrows without altering rep.

Typing a comment and clicking up-vote or down-vote does the same as above and the comment is discarded.

Dani: YES.

--

Dani: It makes sense to me that when you fill out a form, that form is submitted either via the submit button immediately following it, or by hitting Enter.

Of course it makes sense to you. You designed it that way. What makes sense to me (the user) is that if I take the time to write a comment, it isn't thrown away when I cast my vote, either Up- or Down-.

I remember during a discussion about whether full working code given as an response to a question should be deleted or not you responded with (paraphrasing) "I would be upset doing all that work and having my post deleted" therefore, we do not delete cheating posts. But here you have no qualms about "deleting the work making a comment" (and with no warning at all) even though there is an argument againt it.

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

nitin1 is correct.

With a little more detail:

Any number that starts with a zero is interpreted in base 8 (octal) rather than base 10 (decimal). Therefore your 011 is: one 8 and one 1 rather than one 10 and one 1.

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

We don't write code anymore. We make you do it! ;-D

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

If you want to ask a new question, there are two things you need to understand:

1: Make a new article

Don't just add to a totally unrelated article, even if it's your own.

2: Study this:

You obviously didn't understand the first time, so here it is spelled out in detail (#9 is especially pertinant in your case):

[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 …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My question at this moment, two+ hours later is: "did you
1) wait two hours for an answer and do nothing?"
2) try your idea to see if it worked so you'd know if it works?"

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

I claim your swap is not doing what you want it to do. So, here's your first lesson in debugging.

I am assuming you want to swap two elements of the array. (If this is not true, ignore the rest of this post.)
I claim it is not performing the function you want.

Before the call to `swap()`, add a `for()` loop to output the entire array, followed by a newline.
After the call to `swap()`, add a `for()` loop to output the entire array, followed by `getchar()` to stop the program.
Compare the two outputs.
Did it swap?
If so, fine. If not, why?

Outputting values like this is the easiest way to debug a program rather than waiting hours for one of us to fix it for you. It doesn't always work, but it's a lot better than just changing code at random without thinking and hoping for the best.

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

And what is in x and y? Look carefully at your code. It is NOT what you think. And even if it was, how would that affect the array itself?

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

OK, so now the bug is fixed. When we enter a carefully worded comment and click the arrows (as is logical to vote up or down) the comment is completely thrown away and no indication is given that your comment was a waste of time.

So now we need a popup saying "By clicking that arrow your comment will NOT be recorded. Is that what you really want to do?"

User interface -- tell the user that what he did is NOT going to be done as expected.

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

can you please help me with this..

Sure we can, don't get your knickers in a twist!

The best help you can get is format your code. Most likely your problem will become immediately apparent.

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

That completely depends on what you are trying to do there. You are asking for 2 types of functionality:
1) enter letters and use them as is
2) enter numbers and convert them to binary

Which do you want? What if you want to enter the character '6'? You can't do it. Your code only handles the number 6.

Think about it...

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

That is a bubble sort, not a selection sort.

Get rid of the variable y, it's getting in your way.

When you call swap() what values are you supposed to pass to it? The index of the values, or the values themselves?

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

Doesn't work means that my function is not working the way I want it to.

Then, with that detailed information, the answer is "then you did something wrong and have to figure out what it is". If you took your car to get fixed and gave them that explanation, what do you think they'd say?

I have a question to ask you WaltP, can I use award_amount in my getScholarship_Money function after I get the result of award_amount? (As long as I call getAwardAmount() before the getScholarship_Money function?

Now that is a question we can answer. Yes.

You can pass function2() into function1() as a parameter, but in function1() it's just a variable name. Not a function.

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

FYI: Dani and I typically use Area 51 for testing stuff in production so as to avoid cluttering the publicly viewable forums with such things.

Based on my test in Area 51, no rep comments are saved. I voted both Dani And James and no comments see to have been logged at all.

Oh yeah, you were going to break (IMO) the functionality.

OK, so comments are stored but no rep. It's Area 51 after all... I was interested in testing commants and rep here.

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

You've pretty much got it...

The explanation I was looking for you stepped around rather than stating directly (understandably).

When you put a char into an int (or int into double, char into double, etc) the compiler does a translation to 'make it fit'. That's also true when calling or returning from a function.
It's safe up to a point. If you put an int 130 into a char, you will lose some of the number. That's what you have to be careful about.

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

Correct. File handling is what you need.

In a nutshell,

read a file of name/password pairs.
accept info from user.
search through the file data for a match.

What you need to do is

* sit at a desk, paper and pencil, and NO computer.
* write down all the functionality you need
        registration
        list available movies
        all the stuff you need for your store
* write out the order you need things to be done
* start itemizing the steps each item needs, breaking them into 
    smaller and smaller pieces of information until you get it 
    small enough to actually write code.
    ALL the above is NOT done in code. It's done in words, so your 
    younger sister will understand it.
* When you get it broken down into small enough pieces, turn the computer 
    on and start translating that into code

This is a basic technique used for ALL projects.

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

owenransen, you are completely correct. The reason is the \ character defines the next character as an 'escaped' character.
\n = new line
\f = form feed
\t = tab
etc.

So, myfile=fopen("C:\Documents and Settings\Migs\Desktop\test.txt","r"); contains 2 escaped D's, 1 escaped M, and 1 escaped T (tab). That does not make a valid path.

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

i think im getting it now :) thanks for pointing it out :)

Looks like you are...

the char byte gets copied into the lowest byte of int.
....
(0--0)(0--0)(0--0)(10000001)

Good...

i dont think an integer can give 'A' output to the console... although data stored is the same...

Try it... Define a char and and int. Load 65 into both. Now output both. What happens? Why?

did i make sense?

You're doing good :)