Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with determining score for a user.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
koolkid98




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Bobrobyn




PostPosted: 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.
Remm




PostPosted: 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]
codemage




PostPosted: 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.
Clayton




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: