Help with determining score for a user.
Author |
Message |
koolkid98
|
Posted: Wed May 10, 2006 8:36 am Post subject: Help with determining score for a user. |
|
|
Hey........ i have this program i am doing for school, either i pass this task or i fail ok.... i made a program but it doesnt work can you guys please tell me whats wrong with it? Also i was wondering how you can make a point system to this program where every time someone answers the question right they are rewarded with one point and if they answer it wrong they get -1 point..... help me please
code: | var music : string
var point : int
var song : string
point:= 0
put "This is a two players Trivia game followed by a point system, person who answers the most questions correctly wins."
put "What song is currently playing ?"
get song
if song := Bitter Sweet Sympthony then
put "correct, you have", point+1, "Points"
end if |
thnks, Jim |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Bobrobyn
|
Posted: Wed May 10, 2006 9:00 am Post subject: Re: Hey i need help desperatly on this program |
|
|
I think the main problem is the lack of quotes around the Bitter Sweet Sympthony. It SHOULD look like this:
code: |
if song := "Bitter Sweet Sympthony" then %This is a string, it needs quotes for % comparisons
put "correct, you have", point+1, "Points"
end if
|
For the point system, you need to ADD a point if the user is correct, otherwise you need to SUBTRACT a point -- Also, in class, you NEVER EVER do calculations in put statements. You lose marks.
code: |
var music : string
var point : int
var song : string
point:= 0
put "This is a two players Trivia game followed by a point system, person who answers the most questions correctly wins."
put "What song is currently playing ?"
get song
if song := "Bitter Sweet Sympthony" then
point := point + 1
put "correct, you have ", point, " Points"
else
point := point - 1
put "Wrong, you have ", point, " points"
end if
|
Another suggestion - format your code properly! Another small tidbit - for something like this, you could have it set up like a multiple choice test. That way, if a person doesn't know the spelling, they can still answer. |
|
|
|
|
![](images/spacer.gif) |
Remm
![](http://compsci.ca/v3/uploads/user_avatars/154615357445a6b2bc5c032.gif)
|
Posted: Wed May 10, 2006 9:05 am Post subject: (No subject) |
|
|
First of all, your going to need to change the
get song
to
get song:*
or it will only register the first word.
Also, you will need two variables to hold the two players
points, and instead of having 'points + 1' in your sentance, you'll need
to have it just put into a variable
e.i.
p1points := p1points + 1
have somthing also to tell which player is imputing data, so it knows who to give the point to. A good place to look is the Turing Walkthrough for further referance.
Good luck
Remm[/code] |
|
|
|
|
![](images/spacer.gif) |
codemage
![](http://usera.imagecave.com/codemage/codemage-small.gif)
|
Posted: Wed May 10, 2006 1:23 pm Post subject: (No subject) |
|
|
For someone who only has 9 bits, you've already very much on the ball, Remm. |
|
|
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Wed May 10, 2006 3:22 pm Post subject: (No subject) |
|
|
also in your code
Turing: |
if song:= whatever
end if
|
doesnt work, it has to be
Turing: |
if song=whatever then
end if
|
|
|
|
|
|
![](images/spacer.gif) |
|
|