Alice Community  

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

Thread Tools Display Modes
Quadratic Formula
Junior Member
Status: Offline
Posts: 11
Join Date: Mar 2012
Default Quadratic Formula - 04-19-2012, 03:15 PM

I'm working on a program that calculates the answer to the quadratic formula based on inputs from the user for each co-efficient. The book states to use functions called discriminant, SolutionOne, and SolutionTwo (since there are 2 possible solutions for each quadratic formula). I am not the best at functions (much more comfortable with methods & variables).

Do I set these SolutionOne and SolutionTwo functions as boolean, numeric, string, or something else?

In order to code the quadratic formula
x= (-b +- [square root of (b^2 - 4ac)])/2a

do I use a If/else statement, since that seems to be the only option I have when using functions?

Any hints or pointers in the correct direction would be greatly appreciated?
Attached Files
File Type: a2w quadratic_formula.a2w (982.2 KB, 56 views)
Reply With Quote
Senior Member
TauTrumpsPi's Avatar
Status: Offline
Posts: 399
Join Date: Mar 2011
Location: The diamond layer
Default 04-20-2012, 08:36 AM

For the first thing, your formula is wrong. Doing it like that, the program would follow order of operations and divide by 2, then multiply by a. Make sure you put your 2a in parantheses, (2a).

You should make it a numeric return, as you are returning the value of a numeric answer.

I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes

Wondering about my Avatar?

Wondering about my username?
Reply With Quote

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 ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.