Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Need help populating a variable and adding the inputs.
Old
stackrouse
Junior Member
 
Status: Offline
Posts: 2
Join Date: Sep 2011
Default Need help populating a variable and adding the inputs. - 11-02-2011, 07:54 PM

Ok, so I'm trying to make a character average some grades that a user inputs. So I created a method for computeAverage. But I'm having a little trouble with the user inputs. My average is only use the last user input in the equation and I don't know how to a)store the ALL the inputs the user gives me for his/her grades, b)add those together so I can divide.

Here is a screenshot of what I have so far, I'll also upload my world.





Any help? Thanks
Attached Files
File Type: a2w average.a2w (794.5 KB, 10 views)
   
Reply With Quote
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 11-03-2011, 08:28 AM

This is what is happening, let's assume I have 3 grades :

Enter your grades?
User enters say : 87
Now grade = 87.

Enter your grades?
User enters say : 98.
Now grade = 98<--------Notice how 87 was overrided.

Enter your grade?
User enters say : 85.
Now grade = 85.<--------Again see how the computer did not store the previouse grades

There are two ways that you can fix this, I believe the easiest way is to just add.

So change
Code:
grade set value to ask user for a number question=Enter grades?
To :
Code:
grade set value to grade + ask user for a number question=Enter grades?
Now we are adding the previous value of grade to the newly entered value.

Hope this helps.


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein

Last edited by legolizard; 11-03-2011 at 08:32 AM.
   
Reply With Quote
Old
stackrouse
Junior Member
 
Status: Offline
Posts: 2
Join Date: Sep 2011
Default 11-03-2011, 02:34 PM

Thanks for your reply, after playing with this for like 3 HOURS lastnight, lol, I finally figured it out.

I ended up with...

   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.