Not Yet Answered # Help please

leelee 11 Discussion Starter mrsmole leelee 11 Discussion Starter mrsmole leelee 11 Discussion Starter mrsmole Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

Do you know how to code in Pascal at all?

Have you made an attempt any this code yet?

What are your thoughts on how you might begin to tackle this?

(hint: think about the thought processes you'd go through if you were calculating this in your head; write them down)

0

Hi,

I have just started my course and this is the first assignment I have done a little coding and understand the basics.

For the assignment I have to create a program for a hypothetical cash register that will calculate change given leaving the answer in coins. The program will use div and mod which Im ok with using and it also has to include a sensible loop, I understand the loops a little. To be honest though I don't think I could get a formulae to work for that output with a calculator and I thought my maths were pretty good !

Please help, Im not asking for the assignment to be done for me just a nudge in the right direction.

Many Thanks

;)

0

Of course you could do it in your head: it's easier than you think. I would approach it this way:

You have a price, *p*, and an amount of money given, *m*. I would hope the *m > p*, but I'd put in a check to ascertain the veracity of this.

Now, to calculate the change, *c*, it's simply a matter of *m-c*.

Now, we have a discrete number of coins, say 50p, 20p, 10p, 5p, 2p and 1p.

There are usually a number of ways in which *c* can be made up from these denominations: 15p can be 15x1p; 3x5p; 1x10p+1x5p; etc.. For the purposes of this exercise, I'll assume that you want as many large denomination coins as possible.

So work through the coins in order: if I need 47p change, start with the largest denomination:

- 50p. How many 50p in 47p? 0.
- now 20p. How many? 2! That's 2x20p and 7p left to get...
- now 10p. How many 10s in 7? 0.
- now 5p. How many 5s in 7? 1! That's 2x20p, 1x5p and 2p left
- now 2p. How many 2s in 2? 1!

So list out the number of coins, and Bob is your Mother's Brother.

Now make sure you understand this method, make any improvements you deem necessary, write it out neatly as a series of steps, then try and fit those constructs you mentioned earlier to the steps in the algorithm.

Finally, and this shouldn't take long now that it's all written out and you know what you're doing, begin coding.

0

I think Ive got it now, I use to my loop do do the divisions.Can I come back to you for further help if I get stuck?

Thanks for this Ive landed myself in a class were everyone else is slightly more advanced than me ! :eek:

Thanks again for your help x

:)

0

No problem.

Glad to see you've worked it out. Jumping in at the deep-end might seem daunting at first, but if you have patience and are able to think about things, then it's the quickest way to learn.

I'd be interested to see your code when you've finished.

0

I was going to ask you to have a quick look at it when it was done anyway, just incase !

Im going to have a good go at it over the weekend and see what happens......watch this space !

Thanks again, will post when it's done.

Cheers for your help.

:cheesy:

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...