The Student Room Group

AQA AS Computing Skeleton Code 2014

Scroll to see replies

I'm sure for reading its openmode.input?
I am using Pascal, I was wondering if anyone has found a working solution to finding the probability of the next card being higher than the currently turned over card? Any help will be great
Reply 102

create a new function called GetOdds


Function GetOdds(Card:TCard):integer;
Begin
GetOdds := Round((13-Card.Rank)/13 *100);
End;

then change the play game procedure to work with the function you just created

Procedure PlayGame(Deck : TDeck; Var RecentScores : TRecentScores);
Var
NoOfCardsTurnedOver : Integer;
GameOver : Boolean;
LastCard : TCard;
NextCard : TCard;
Higher : Boolean;
Choice : Char;
Odds : integer
Begin
GameOver := False;
GetCard(LastCard, Deck, 0);
DisplayCard(LastCard);
NoOfCardsTurnedOver := 1;
While (NoOfCardsTurnedOver < 52) And Not GameOver
Do
Begin
GetCard(NextCard, Deck, NoOfCardsTurnedOver);
Odds := GetOdds(LastCard);
Writeln('Chance of next card being higher is ', odds,'%');

Repeat
Choice := GetChoiceFromUser;
Until (Choice = 'y') Or (Choice = 'n');
DisplayCard(NextCard);
NoOfCardsTurnedOver := NoOfCardsTurnedOver + 1;
Higher := IsNextCardHigher(LastCard, NextCard);
(edited 9 years ago)
im so worried for this exam :/
Hey guys, I posted most of my solutions on my blogpost if you're curious.

http://thisisthien.com/blog/post/AQAPreliminary/
Original post by seb1235
ok i need help :frown:
i want to be able to save the recent scores in a text file, i've almost done it, however i can only save the most recent score.. not all 3 and i have no idea what im doing wrong :/ can anyone help me?

def save():
for Count in range(1, NO_OF_RECENT_SCORES + 1):
b= str(RecentScores[1].Score)
c= str(RecentScores[1].Name)
a=open('Recent.txt', 'w')
line =a.writelines(c + ' got a score off ' + b)
return Choice

Thats the code I added (simply added a 5th option for this user defined function on the menu ), but it will only ever display the first score..
this is all the code with my modifications...
https://drive.google.com/file/d/0B43plQVMZbhWYkFCSkFCTi04cjQ/edit?usp=sharing
if anyone can help that would be great.. Thanks!


I haven't studied the programming language you've used, however your recentscores has a (1) in it and not a variable. Such as count, in fact count appears no where in that for loop.

It's make sense for it to only save 1 scores if a (1) was the only number in there. Maybe replace 1 with count? And see if that works?

I may not just not understand the language but that seems like a potential problem to me.
Hey, I already had something similar to this, except this isn't the full solution because as each card is drawn there is one less card in the deck. Meaning, the maths you had used is not entirely correct. For example, if you have already drawn all 4 kings and all 4 queens and you draw your first jack, the probability of the next card should be 0%, not 15%.
potential questions with answers in codes- all languages from Java to visual basics
http://revise4exam.weebly.com/comp1-2014-potential-qa.html
Probable questions:

Intermediate

-Read/write scores to a text file
-Sort scores using bubble sort

Easy

-If a card has the same value, draw or base the outcome on the value of the suit
-Disallow empty names
-Make ace high
-Quit during a game
(edited 9 years ago)
Does anyone have a solution for ranking the scores in pascal?
What is an example of a most recent variable role, a stepper and and fixed value. I'm confused any help would be appreciated!
For all those using VB, here is how you would store the scores in the simplest way:


Module TestingCode




Dim path As String = "C:\test.bin"
Dim i As Integer


Structure TScore
Dim name As String
Dim score As Integer
End Structure


Dim Scores(2) As TScore
Dim ReadScores(2) As TScore




Sub Main()
Scores(0).name = "Bob"
Scores(0).score = 21


Scores(1).name = "Sam"
Scores(1).score = 56


Scores(2).name = "Chris"
Scores(2).score = 34


Write()
Read()
Print()
End Sub
Sub Write()


FileOpen(1, path, OpenMode.Binary, OpenAccess.Write)
FilePut(1, Scores)
FileClose(1)


End Sub


Sub Read()


FileOpen(1, path, OpenMode.Binary, OpenAccess.Read)
FileGet(1, ReadScores)
FileClose(1)


End Sub


Sub Print()


For Each N In ReadScores
Console.WriteLine(N.name)
Console.WriteLine(N.score)
Next


End Sub


End Module


Original post by HugeBicepLAD
What is an example of a most recent variable role, a stepper and and fixed value. I'm confused any help would be appreciated!


Fixed:

Const Pi As Integer = 3.142

Stepper:
Dim i as integer = 0

For i = 0 to 10
'Do Stuff
Next

Most Recent:

Dim LatestInputGot as String

LatestInputGot = Console.readline()..
Original post by AdilMalikN
Fixed:

Const Pi As Integer = 3.142

Stepper:
Dim i as integer = 0

For i = 0 to 10
'Do Stuff
Next

Most Recent:

Dim LatestInputGot as String

LatestInputGot = Console.readline()..


Thanks! Just to clarify is a fixed value variable the same thing as a constant?
Original post by HugeBicepLAD
Thanks! Just to clarify is a fixed value variable the same thing as a constant?



Yup, a constant. AQA has this thing for confusing the hell out of people by using their own different names for stuff...
Reply 115
Are these variables correct:

Fixed Value - NoOfRecentScores
Temp - SwapSpace
Most Recent Holder - PlayerName
Stepper - Count
Most Wanted Holder - ?
Gatherer - NoOfCardsTurnedOver
etc?
(edited 9 years ago)
Original post by noreld
Are these variables correct:

Fixed Value - NoOfRecentScores
Temp - SwapSpace
Most Recent Holder - PlayerName
Stepper - Count
Most Wanted Holder - ?
Gatherer - NoOfCardsTurnedOver
etc?


Original post by AdilMalikN
Yup, a constant. AQA has this thing for confusing the hell out of people by using their own different names for stuff...


This is where I get confused. My teacher proclaimed that a constant isn't a variable. As it's constant therefore it is not a variable so it can't have a type? However my teacher has been known to not be very reliable when it comes to this subject. So I'd like some clarity as to whether this is truly the case?
Const number as integer = 1

This is how you would declare a constant
Your teacher is probably saying because constants don't change so there is no need to declare it as a type as it never changes.


At least that's my opinion. Someone correct me if I'm wrong cos I'm still learning after all :smile:
Original post by dominicwild
This is where I get confused. My teacher proclaimed that a constant isn't a variable. As it's constant therefore it is not a variable so it can't have a type? However my teacher has been known to not be very reliable when it comes to this subject. So I'd like some clarity as to whether this is truly the case?




You cant declare a variable/store a value without declaring its type. Every declaration must have type. Even if you dont see it VB gives it the most appropriate data type.

The definitions isnt strict, you dont really need to define it with "Const". Just pick any variable in the context of the program that doesnt change throughout. Yes NoofRecentScores can be a constant also because even though it hasnt been defined as a "Const" we arnt changing it.

So the simple things to look out for is:

Doesn't Change

Used repeatedly in the program, for example the Size of some array..
Pretty certain there gonna ask us to write scores to a textfile.

However would they really ask us to do a bubblesort? im not saying its hard but for the way i do its soooo time consuming ;/

Quick Reply

Latest

Trending

Trending