The Student Room Group

AQA AS Computing Skeleton Code 2014

Scroll to see replies

If you take a look at the Java code they released, they have kept separate classes called AQAReadTextFile2014 and AQAWriteTextFile2014

This suggests that they will ask to save something to a text file then read from it??

In my opinion i think they will ask to write the high scores to a text file.

This has been asked before and it was worth 10 marks, so yes it can be asked again.

Im using Visual Studio and this is what i have so far, im sure if it will even work haha :smile:


Sub SaveTopScoresToTextFile (ByVal TopScores() As TRecentScore)
Dim Count As Integer
Dim LineToAddToFile As String
FileOpen(1, "AQAWriteTextFile2014.txt", OpenMode.Output)
For Count = 1 To MaxSize
LineToAddToFile = TopScores(Count).Name & "," &
TopScores(Count).Score
PrintLine(1, LineToAddToFile)
Next
FileClose(1)
End Sub


That code is from the mark scheme of another paper i just swapped some stuff around, i havent tested it.

But yes there is a good chance this question will be asked.

Or they could ask us to read the deck.txt file and display the contents of that in the console?




there's a high chance that a question like that may come up which requires you to read the high scores from a text file and save any new scores to that file
here's the code to save new scores into a text file, just uses a simple for loop which has 3 iterations extracting the recent scores each time and saving it to the text file...
easy to code it to load scores aswell just use logic :smile:
Sub SaveScores(ByVal recentscores() As TRecentScore)

Dim scorewriter As New System.IO.StreamWriter("scores.txt")
For g = 1 To 3


scorewriter.WriteLine("Player Name:" & recentscores(g).Name)
scorewriter.WriteLine("Player Score:" & recentscores(g).Score)
'scorewriter.Write("")




Next
scorewriter.Close()




End Sub
That is another good suggestion, however in the mark scheme for the previous exam where they asked to write to a text file no mark scheme answer included the use of the steamwriter.io :/
I don't see why they wouldn't give any marks, its the exact same thing just a more effecient way of doing the process. Ill ask my computing teacher on Monday about it as he marks the IT and computing papers every year so hopefully he can clarify.
Original post by Aspolale
I don't see why they wouldn't give any marks, its the exact same thing just a more effecient way of doing the process. Ill ask my computing teacher on Monday about it as he marks the IT and computing papers every year so hopefully he can clarify.



Ok yes that would be great,
please get back to me once you find out :wink:
I've have already told some via pm: although it's an very valid (and better) alternative, I don't think it'll be on the mark scheme as it is very specific to the .NET framework. Assuming the makers are allowed to deviate from the mark scheme, you'll still need an examiner who's used VB.NET in order to understand it, which is no gurt.
I suggest that you use the same method as is already in the Skeleton code, taking no risks.

This exam is not your time to show off, it's your time to jump through the hoops, dot the "i"s and cross the "t"s. No point throwing away marks just for knowing the language better than the examiner.

Posted from TSR Mobile
There isn't already a way it's done in the skeleton code? I don't quite understand your point due to this? Are you saying to use the way that I posted above?

Kind regards
- Super


Posted from TSR Mobile
Update sorry its taken such a long time but i've been able to confirm with my teacher that my way of saving and loading the scores is a valid way and will be in the markscheme.
My teacher has emailed aqa to confirm this /etc. the reason it wasn't in previous mark schemes was because it wasn't a widely used way whereas now it is typically used alot more..
Hope this helps, if you guys need any help pm me ...
Original post by Aspolale
Update sorry its taken such a long time but i've been able to confirm with my teacher that my way of saving and loading the scores is a valid way and will be in the markscheme.
My teacher has emailed aqa to confirm this /etc. the reason it wasn't in previous mark schemes was because it wasn't a widely used way whereas now it is typically used alot more..
Hope this helps, if you guys need any help pm me ...


Ok thanks :smile:
Reply 69
Well if u guys need help finding solutions or ideas for questions they might ask wikibooks has quite a few you good give a try they also have solutions for them aswell
my website has a lot of resources regarding AS computing and physics - its ahmedabokor.weebly.com
Reply 71
i found this piece of code on the net for vb. its meant to calculating the probability of the next card being higher, can anyone make any sense of it?
here it is:



Function probabilityHigher(ByVal lastCard As TCard) As Integer
Dim HigherProb As Integer
Dim TotalCards As Integer = 64
Dim RankProb(12) As Integer
For i = 0 To 12
Select Case i
Case "0"
RankProb(0) = 48
Case "1"
RankProb(1) = 44
Case "2"
RankProb(2) = 40
Case "3"
RankProb(3) = 36
Case "4"
RankProb(4) = 32
Case "5"
RankProb(5) = 28
Case "6"
RankProb(6) = 24


Case "7"
RankProb(7) = 20
Case "8"
RankProb(8) = 16
Case "9"
RankProb(9) = 12
Case "10"
RankProb(10) = 8
Case "11"
RankProb(11) = 4
Case "12"
RankProb(12) = 0
End Select
Next


If lastCard.Rank = 1 Then
HigherProb = RankProb(0) / TotalCards * 100
If RankProb(0) <> 0 Then
RankProb(0) = RankProb(0) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 2 Then
HigherProb = RankProb(1) / TotalCards * 100
If RankProb(1) <> 0 Then
RankProb(1) = RankProb(1) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 3 Then
HigherProb = RankProb(2) / TotalCards * 100
If RankProb(2) <> 0 Then
RankProb(2) = RankProb(2) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 4 Then
HigherProb = RankProb(3) / TotalCards * 100
If RankProb(3) <> 0 Then
RankProb(3) = RankProb(3) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 5 Then
HigherProb = RankProb(4) / TotalCards * 100
If RankProb(4) <> 0 Then
RankProb(4) = RankProb(4) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 6 Then
HigherProb = RankProb(5) / TotalCards * 100
If RankProb(5) <> 0 Then
RankProb(5) = RankProb(5) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 7 Then
HigherProb = RankProb(6) / TotalCards * 100
If RankProb(6) <> 0 Then
RankProb(6) = RankProb(6) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 8 Then
HigherProb = RankProb(7) / TotalCards * 100
If RankProb(7) <> 0 Then
RankProb(7) = RankProb(7) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 9 Then
HigherProb = RankProb(8) / TotalCards * 100
If RankProb(8) <> 0 Then
RankProb(8) = RankProb(8) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 10 Then
HigherProb = RankProb(9) / TotalCards * 100
If RankProb(9) <> 0 Then
RankProb(9) = RankProb(9) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 11 Then
HigherProb = RankProb(10) / TotalCards * 100
If RankProb(10) <> 0 Then
RankProb(10) = RankProb(10) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 12 Then
HigherProb = RankProb(11) / TotalCards * 100
If RankProb(11) <> 0 Then
RankProb(11) = RankProb(11) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 13 Then
HigherProb = RankProb(12)
TotalCards = TotalCards - 1
End If
Return HigherProb
End Function
Original post by khaaaaan
i found this piece of code on the net for vb. its meant to calculating the probability of the next card being higher, can anyone make any sense of it?
here it is:



Function probabilityHigher(ByVal lastCard As TCard) As Integer
Dim HigherProb As Integer
Dim TotalCards As Integer = 64
Dim RankProb(12) As Integer
For i = 0 To 12
Select Case i
Case "0"
RankProb(0) = 48
Case "1"
RankProb(1) = 44
Case "2"
RankProb(2) = 40
Case "3"
RankProb(3) = 36
Case "4"
RankProb(4) = 32
Case "5"
RankProb(5) = 28
Case "6"
RankProb(6) = 24


Case "7"
RankProb(7) = 20
Case "8"
RankProb(8) = 16
Case "9"
RankProb(9) = 12
Case "10"
RankProb(10) = 8
Case "11"
RankProb(11) = 4
Case "12"
RankProb(12) = 0
End Select
Next


If lastCard.Rank = 1 Then
HigherProb = RankProb(0) / TotalCards * 100
If RankProb(0) <> 0 Then
RankProb(0) = RankProb(0) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 2 Then
HigherProb = RankProb(1) / TotalCards * 100
If RankProb(1) <> 0 Then
RankProb(1) = RankProb(1) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 3 Then
HigherProb = RankProb(2) / TotalCards * 100
If RankProb(2) <> 0 Then
RankProb(2) = RankProb(2) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 4 Then
HigherProb = RankProb(3) / TotalCards * 100
If RankProb(3) <> 0 Then
RankProb(3) = RankProb(3) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 5 Then
HigherProb = RankProb(4) / TotalCards * 100
If RankProb(4) <> 0 Then
RankProb(4) = RankProb(4) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 6 Then
HigherProb = RankProb(5) / TotalCards * 100
If RankProb(5) <> 0 Then
RankProb(5) = RankProb(5) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 7 Then
HigherProb = RankProb(6) / TotalCards * 100
If RankProb(6) <> 0 Then
RankProb(6) = RankProb(6) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 8 Then
HigherProb = RankProb(7) / TotalCards * 100
If RankProb(7) <> 0 Then
RankProb(7) = RankProb(7) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 9 Then
HigherProb = RankProb(8) / TotalCards * 100
If RankProb(8) <> 0 Then
RankProb(8) = RankProb(8) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 10 Then
HigherProb = RankProb(9) / TotalCards * 100
If RankProb(9) <> 0 Then
RankProb(9) = RankProb(9) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 11 Then
HigherProb = RankProb(10) / TotalCards * 100
If RankProb(10) <> 0 Then
RankProb(10) = RankProb(10) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 12 Then
HigherProb = RankProb(11) / TotalCards * 100
If RankProb(11) <> 0 Then
RankProb(11) = RankProb(11) - 1
End If
TotalCards = TotalCards - 1
ElseIf lastCard.Rank = 13 Then
HigherProb = RankProb(12)
TotalCards = TotalCards - 1
End If
Return HigherProb
End Function



Hi khan,

I have found another way of doing this probability question. This code you suggested is way to confusing So I have shortened the code and made it easier to understand. Good luck

Sub ShowProbabilty(ByVal Deck() As TCard, ByVal LastCard As TCard, ByVal NoOfCardsTurnedOver As Integer)

Dim NumberOfHigher As Integer
Dim PercentageOfHIgher As Integer
Dim PercentageOfLower As Integer

For Count = 1 To (52 - NoOfCardsTurnedOver)
If Deck(Count).Rank >= LastCard.Rank Then
NumberOfHigher = NumberOfHigher + 1
End If
Next
PercentageOfHIgher = (NumberOfHigher / (52 - NoOfCardsTurnedOver)) * 100
PercentageOfLower = 100 - PercentageOfHIgher

Console.WriteLine()
Console.WriteLine("The percentage of the next card being higher = " & PercentageOfHIgher & "%")
Console.WriteLine()
Console.WriteLine("The percentage of the next card being lower = " & PercentageOfLower & "%")
Console.WriteLine()

End Sub
Oh i forgot you will also need to call this sub from

Sub PlayGame(ByVal Deck() As TCard, ByRef RecentScores() As TRecentScore)
Dim NoOfCardsTurnedOver As Integer
Dim GameOver As Boolean
Dim NextCard As TCard
Dim LastCard As TCard
Dim Higher As Boolean
Dim Choice As Char
Dim Lives As Integer = 2
Dim Lower As Boolean
Dim NoOfSwaps As Integer = 3

GameOver = False
GetCard(LastCard, Deck, 0)
DisplayCard(LastCard)
NoOfCardsTurnedOver = 1

While NoOfCardsTurnedOver < 52 And Not GameOver
ShowProbabilty(Deck, LastCard, NoOfCardsTurnedOver)
GetCard(NextCard, Deck, NoOfCardsTurnedOver)
Reply 74
Sweet thanks man
no problem buddy :smile:
I doubt a question will ask you to load from a file
Reply 77
Oh it will, besides its not that difficult
Reply 78
I personally think they'll ask us to do a bubble sort on the recent scores. There's simply not enough time in the exam to complete a bubble sort and saving/reading from a textfile.

*Assuming they ask us to validate inputs, etc.

Also, could I get away with another algorithm, for example a shell sort?
(edited 9 years ago)
Reply 79
hi lads

my teacher isnt really helping us much.
i was wondering if someone can post how to do the bubble sort on visual basic using the skeleton program?
cheers

Quick Reply

Latest

Trending

Trending