Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AQA CPT3 2008 - Peter's Petrol Pumps - Again :)

6 views
Skip to first unread message

Mr Nozza

unread,
Apr 29, 2007, 8:08:11 AM4/29/07
to
Has anyone made any progress on AQA CPT3 2008 - Peter's Petrol Pumps
in either VB or VB Express?

I have spent hours creating a form and am some way off getting
anything resembling a working solution. So, I'm looking for help and
advice on this.

For info I am now thinking I'll have to use VB6 despite its age - and
the fact VB Express is free - so pupils can download at home.

Usual caveats apply - this is an exam board task so other than very
general pointers here, it's probably best to email me (goes against
the spirit of Usenet and all that.

As ever, hints, tips and thoughts welcome

Mr Noz
--
Email
mr_noz...@yahoo.co.uk

Howard

unread,
Jun 26, 2007, 5:49:06 PM6/26/07
to
Just came across this. Hooray, at least one other person on this NG does
computing, and AQA to boot!
I was beginning to think that none of my computing related questions were
ever going to get replies as nobody else did computing at A level.

Without wishing to sound immodest, I did this one in my head a while back
and knocked out a small prototype. I then put it down for a while as
pressure was on to complete UKEB.
I 'll improve on what I've done and get back to you.

BTW I have worries every year whether to teach Pascal or VB (or even C++).
Pascal as its what the book uses and is much better for university, VB as
its easy and good for doing serious database work in office products. I put
VB express on the system but warned the kids off off it as it requires far
too much full path declarations and the housekeeping gets in the way (same
is true of more modern Pascals) in the end I opted this year for VB6 as it
is simple, does the job and is reasonably powerful.

For assembly I use a free 6502 emulator


Howard


"Mr Nozza" <nozza_a...@yahoo.co.uk> wrote in message
news:oc2933tufmkhi8ui1...@4ax.com...

Mr Nozza

unread,
Jun 28, 2007, 11:55:23 AM6/28/07
to
On Tue, 26 Jun 2007 22:49:06 +0100, "Howard"
<nos...@home.please.co.uk> wrote:

>Just came across this. Hooray, at least one other person on this NG does
>computing, and AQA to boot!
>I was beginning to think that none of my computing related questions were
>ever going to get replies as nobody else did computing at A level.

I think we're a dying breed.

>Without wishing to sound immodest, I did this one in my head a while back
>and knocked out a small prototype. I then put it down for a while as
>pressure was on to complete UKEB.
>I 'll improve on what I've done and get back to you.

That would be great. It's the LCD I'm having trouble with - with 7
elements per number, and about 12(?) digits to code in 3 groups it's
going to be a complex algorithm to get working well. I've tried - and
am maybe missing something.

As for the trigger I'm thinking along the lines of a command button to
randomly serve up up to 50 litres, or a slider control going up to 50
litres.

I'd dearly love to see what you have so far.

UKAB this year was just the right level for my group, it got them
thinking and coding, but the amount of coding needed for next year
seems *way* beyond anything my candidates would normally experience.

For assembly I use a free 6502 emulator

We've been using the TOM simulator, and they did well I thought this
year. Until the CPT4 exam!

lornap...@googlemail.com

unread,
Aug 1, 2007, 8:33:44 AM8/1/07
to
> mr_nozza2...@yahoo.co.uk

Just starting the petrol pumps will let you know how I get on. It
seems the board have said that the students can't get to grips with OO
programming, yet this problem is ideally suited to this. My students
will find this extremely difficult!!

Mr Nozza

unread,
Aug 1, 2007, 11:37:50 AM8/1/07
to

>Just starting the petrol pumps will let you know how I get on. It
>seems the board have said that the students can't get to grips with OO
>programming, yet this problem is ideally suited to this. My students
>will find this extremely difficult!!

The latest version of the spec is dated 17/7/07 and has some minor
changes to Peters Pumps - so it needs checking out - biggest change I
can see is that the pounds to pay can now be xxx.xx and not just xx.xx

There might be other changes too - but I haven't spotted them yet!

Mr Noz
--
Email (ROT13)
ze_abm...@lnubb.pb.hx

Message has been deleted

fran...@gmail.com

unread,
Sep 25, 2007, 5:42:33 PM9/25/07
to
likewise, i'm new to teaching this one. last year my HOD handled all
of the coursework units cpt3 and cpt6 and let me teach a LOT of
theory. now i'm in a new school teaching the entire AS and A2
computing course and having to quickly get my head around the
coursework elements.

what programming exercises would prepare students to answer this
problem? i've taught them vba so far, just the basics - conditions,
loops, functions. what's going to be needed to handle the 7 segment
display?

Howard

unread,
Sep 26, 2007, 4:21:29 PM9/26/07
to

Don't get your head around it too much as it all changes next year! To
do the 7 seg I'd make sure they can use arrays and then show them what a
control array is using text boxes or rectangles in the shape of house
with a chimney

|
/ \
| |
_ _

Then use a loop to 'build' the house piece by piece. Then introduce the
select case to show only the walls, floor, roof etc by displaying only
certain parts depending upon an integer selector. Then its only a short
step for them to rearrange the house to a 7 seg and see that the select
case can display the required digit given an integer selector.

To get the tens, units etc they need to do a bit of mod and div
arithmetic and have some way of selecting which 7 seg to use.

Howard

bill.r...@which.net

unread,
Oct 6, 2007, 1:45:49 PM10/6/07
to
Hi folks

We have just started AQA Computing this year, having previously only
offered ICT. Although a big fan of Pascal, we elected to use VB,
since my colleague knows it, but is a bit weaker on programming
fundamentals.

Whilst we initially went for VB6, we ended up going VB 2005 Express,
not least of all because of the help facilities.

The Petrol Pump display is actually not as hard as the scare stories
that I have heard flying around. The principle is to set up a
primitive drawing subroutine that can draw a line, from one set of x,y
coordinates to another (with an appropriate pen width and a triangular
start and end cap). Call this seven times with the right coordinates
and you can draw an 8. Next, introduce the idea that if you have two
pens, one coloured and the other blank (same as the form's
background), then you can draw any digit. Set up ten routines,
Zero(), One(), etc... to draw the correct bars to represent each
digit. Ok, so now we can draw a digit, any digit. Next, get them to
write a routine to make their one-digit display count. As
soon as they introduce some Do While - Loops, make sure they
understand the need for an Application.DoEvents() inside the loop or
they won't be able to process any interrupts (mouse-up for the pump).
I would suggest a Select - Case statement to process the digit you are
trying to display, keeps it neat and easier to understand.

Hopefully, they will have a counting digit, that goes 0-9, or some
such, which they may/may not need to slow down a little to see the
counting, depending on how inventive they are.

Next, they need to think about how to display a number larger than 9.
Introduce a FuelLitres variable, that you will increment by .01 inside
a Loop in the MouseDown routine, (here is where the
Application.DoEvents() becomes critical), the only exit from which is
when you reach a pre-determined fuel limit or when the system traps
the MouseUp event. Displaying the fuel (and from that the price) is
an inner loop encapsulating the Select-Case statement to display any
single digit. I will just explain the fuel display... the fuel cost
is a natural extension of this. It goes without saying that this is
not something you want to give to your students directly and I am sure
that there are other ways of doing it.

The basics of all decimal systems is that you multiply by 10 every
decimal place you move to the left, so... In the following routine,
FuelLitres is the amount of fuel, segment is a variable that we will
(in the end) pass to our drawing routine to offset our drawn digit,
depending on whether we are drawing in the Unit, Ten, Hundred, etc...
position. running is a boolean that is set to true when the pump
handle is "lifted". flag is a boolean that we will set to true in the
MouseUp routine, to provide an exit. workvar and OneDigit are integer
variables to hold the fuel value to display and the single digit from
each part of the number that will be stripped out in turn
respectively. DrawMyDigit() is a sub that contains the Select-Case
statement to draw any digit.

Do While FuelLitres < 100 And running And Not flag
segment = 0
FuelLitres = FuelLitres + 0.01
workvar = FuelLitres * 100
Do While workvar > 0
Application.DoEvents()
OneDigit = workvar - (Int(workvar / 10) * 10)
DrawMyDigit(OneDigit, segment)
workvar = Int(workvar / 10)
segment = segment + 1
Loop
Loop

After that, you need to consider a vertical offset for the various
numbers (price, fuel, price per litre) to be displayed.

Have fun!


- Bill

Mr Nozza

unread,
Oct 6, 2007, 3:13:26 PM10/6/07
to
On Sat, 06 Oct 2007 10:45:49 -0700, bill.r...@which.net wrote:


>Whilst we initially went for VB6, we ended up going VB 2005 Express,
>not least of all because of the help facilities.

The help facilities are good aren't they.

They point out that two things that could really make this easy, the
line control, and control arrays are no longer supported :(

>The Petrol Pump display is actually not as hard as the scare stories
>that I have heard flying around. The principle is to set up a
>primitive drawing subroutine that can draw a line, from one set of x,y
>coordinates to another (with an appropriate pen width and a triangular
>start and end cap). Call this seven times with the right coordinates
>and you can draw an 8. Next, introduce the idea that if you have two
>pens, one coloured and the other blank (same as the form's
>background), then you can draw any digit. Set up ten routines,
>Zero(), One(), etc... to draw the correct bars to represent each
>digit. Ok, so now we can draw a digit, any digit. Next, get them to
>write a routine to make their one-digit display count. As
>soon as they introduce some Do While - Loops, make sure they
>understand the need for an Application.DoEvents() inside the loop or
>they won't be able to process any interrupts (mouse-up for the pump).
>I would suggest a Select - Case statement to process the digit you are
>trying to display, keeps it neat and easier to understand.

Chuckle


>Hopefully,

:)

>they will have a counting digit, that goes 0-9, or some
>such, which they may/may not need to slow down a little to see the
>counting, depending on how inventive they are.
>
>Next, they need to think

Now there's a tough one... ;)

>about how to display a number larger than 9.
>Introduce a FuelLitres variable, that you will increment by .01 inside
>a Loop in the MouseDown routine, (here is where the
>Application.DoEvents() becomes critical), the only exit from which is
>when you reach a pre-determined fuel limit or when the system traps
>the MouseUp event. Displaying the fuel (and from that the price) is
>an inner loop encapsulating the Select-Case statement to display any
>single digit. I will just explain the fuel display... the fuel cost
>is a natural extension of this. It goes without saying that this is
>not something you want to give to your students directly and I am sure
>that there are other ways of doing it.
>
>The basics of all decimal systems is that you multiply by 10 every
>decimal place you move to the left, so... In the following routine,
>FuelLitres is the amount of fuel, segment is a variable that we will
>(in the end) pass to our drawing routine to offset our drawn digit,
>depending on whether we are drawing in the Unit, Ten, Hundred, etc...
>position. running is a boolean that is set to true when the pump
>handle is "lifted". flag is a boolean that we will set to true in the
>MouseUp routine, to provide an exit. workvar and OneDigit are integer
>variables to hold the fuel value to display and the single digit from
>each part of the number that will be stripped out in turn
>respectively. DrawMyDigit() is a sub that contains the Select-Case
>statement to draw any digit.

You make it sound so simple - my pupils have just finished week 5 of
the course. Some are still on the "must remember my password"
strand....

>
> Do While FuelLitres < 100 And running And Not flag
> segment = 0
> FuelLitres = FuelLitres + 0.01
> workvar = FuelLitres * 100
> Do While workvar > 0
> Application.DoEvents()
> OneDigit = workvar - (Int(workvar / 10) * 10)
> DrawMyDigit(OneDigit, segment)
> workvar = Int(workvar / 10)
> segment = segment + 1
> Loop
> Loop
>
>After that, you need to consider a vertical offset for the various
>numbers (price, fuel, price per litre) to be displayed.

:)

>Have fun!

Thanks Bill - we will ;)

Mark Hanley

unread,
Oct 7, 2007, 4:37:38 AM10/7/07
to

This petrol pumps exercise sounds fascinating. Could anybody sum up
the exercise so that us non-AQA people can have a look :)

Thanks!
Mark.

Mark Hanley

unread,
Oct 7, 2007, 9:36:52 AM10/7/07
to
> The Petrol Pump display is actually not as hard as the scare stories
> that I have heard flying around. The principle is to set up a
> primitive drawing subroutine that can draw a line, from one set of x,y
> coordinates to another (with an appropriate pen width and a triangular
> start and end cap). Call this seven times with the right coordinates
> and you can draw an 8. Next, introduce the idea that if you have two
> pens, one coloured and the other blank (same as the form's
> background), then you can draw any digit. Set up ten routines,
> Zero(), One(), etc... to draw the correct bars to represent each
> digit.

Rather than setting up 10 drawing routines, wouldn't it be better to
just have one routine that takes an int representing the value of the
digit?
This int - lets call it 'value' - could be used as an index into an
array of 'on/off' values - one for each segment.
All you need then is a way of specifying the start and end points of
each segment.

I just had a go and came up with this (lots left out so as not to
completely give it away!).
I set up a few static arrays to describe each digit value. Segment
start and end coords are specified as XY pairs imagining that you are
drawing to a 1x2 grid (these will be multiplied by a 'digit size'
value).

private static int[,] SegmentStartXY = { { 0, 0 }, { 0, 0 }, { 1, 0 },
{ 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 2 } };
private static int[,] SegmentEndXY = { { 1, 0 }, { 0, 1 }, { 1, 1 },
{ 1, 1 }, { 0, 2 }, { 1, 2 }, { 1, 2 } };
private static string[] DigitMap =
{ "1110111","0010010","1011101","1011011","0111010",
"1101011","1101111","1010010","1111111","1111010"};

The bit of the 'draw' routine then looks like the following. ('value'
refers to the value of the digit being drawn; 'lit' and 'unlit' are
System.Drawing.Pens of the colours you want for ON segments and OFF
segments.)

string map = DigitMap[value];
Point start, end;
for (int i = 0; i < map.Length; i++)
{
this.pen.Color = (map[i] == '1') ? this.lit : this.unlit;

start = new Point(SegmentStartXY[i, 0] * this.digitSize,
SegmentStartXY[i, 1] * this.digitSize);
end = new Point(SegmentEndXY[i, 0] * this.digitSize,
SegmentEndXY[i, 1] * this.digitSize);

g.DrawLine(this.pen, start, end);
}

Sorry it's in C# when most of this thread is n VB. I don't speak VB
I'm afraid.

If you want the complete listing complete with a couple of
incrementing digits in a windows form then let me know.

Mark.

Message has been deleted

deger...@leedslearning.net

unread,
Oct 25, 2007, 6:55:41 AM10/25/07
to

It is tempting to start with the display graphics isn't it. They are
clearly the bit that worries people about the problem.

I was thinking of starting with the problem. Maybe just display the
results in text boxes or labels and then add the interface elements at
the end.

The problem itself is quite small but interesting. I am a little
worried about the control of the filling process. I would not
normally have taught year 12 to handle this kind of situation as it is
not typically found in traditional business data processing problems,
but it is probably good to be challenged in to teaching with a wider
range of problem types. I just wonder whether I would still do that
if board set task was different. I guess from next year we will have
to expect everything and anything!

Deg.

James Sullivan

unread,
Feb 8, 2008, 7:01:59 PM2/8/08
to
I have a basic solution to the problem,
i will not tell you "how to" do it as that would be a shame full approach on
your course, but heres a few ideas ;)
Use a timer object.
For the Seven segment text you could either use 7 labels and change their
color properties in a "Select case",or literally draw 0-9 in paint or
something and call the image in a select case - do this in a subroutine so
you can call it...
Another point, if you have Vb at home install some kind of lcd text font, it
will still be marked! Success :)

url:http://myreader.co.uk/msg/10412777.aspx

MatthewJ...@gmail.com

unread,
Mar 13, 2008, 8:38:07 AM3/13/08
to

You need to set up the form without the seven segment then write a
procedure that takes in a char and outputs a set of segments that are
either visible or invisible I used a case of statment.

I'd like to here if any one used an OO approach??

brian.norep...@googlemail.com

unread,
Mar 20, 2008, 6:42:58 AM3/20/08
to
On 13 Mar, 12:38, MatthewJamesSc...@gmail.com wrote:
> On Feb 9, 12:01 am, "James Sullivan"<F...@fake.com> wrote:
>
> > I have a basic solution to the problem,
> > i will not tell you "how to" do it as that would be a shame full approach on
> > your course, but heres a few ideas ;)
> > Use a timer object.
> > For the Sevensegmenttext you could either use7labels and change their

> > color properties in a "Select case",or literally draw 0-9 in paint or
> > something and call the image in a select case - do this in a subroutine so
> > you can call it...
> > Another point, if you have Vb at home install some kind of lcd text font, it
> > will still be marked! Success :)
>
> > url:http://myreader.co.uk/msg/10412777.aspx
>
> You need to set up the form without the sevensegmentthen write a

> procedure that takes in a char and outputs a set of segments that are
> either visible or invisible I used a case of statment.
>
> I'd like to here if any one used an OO approach??

We have used OOP and java for this course. The students did the seven
segment display a variety of ways but I have a demo ready for after
the exam using masking within a digit object which shows on and off
versions of the display segments as well as painting the background of
the display the same colour.

I would be happy to discuss this generally here, but the details and
any code I will leave until after the exam.

Interestingly I started off with bluej and also used netbeans (bluej
version) and netbeans IDE 6. The students ended up much preferring
bluej for the project as they felt they learned stuff and really owned
their own code. I can see their point really.

Also discovered that if you want to handle bitmaps (as in .bmp windows
format files (although eventually I didn't)) then you need the version
6 upgrade to the compiler.

That took a while.

katebu...@exe-coll.ac.uk

unread,
May 13, 2008, 8:10:19 AM5/13/08
to
Hi
Is it too early to discuss yesterday's CPT3 paper? I have a question
about it, but don't want to ask unless it's now considered 'safe'
Thanks

Nozza

unread,
May 14, 2008, 11:56:33 AM5/14/08
to
In article
<3d69490d-d707-41b2...@y38g2000hsy.googlegroups.com>,
katebu...@exe-coll.ac.uk said...

Safe to discuss today - Weds. There can be a potential problem
dicussing on the day - or even on the day after, as sometimes people
have to sit an exam later in the day - but then they must be
supervised. But by the time wednesday comes along it should be safe!

Go on, what was the question?

Noz

0 new messages