|
Web design and Programming Discuss website creation and other programming topics. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||
|
C# Quadratic Formula Calculator (Beginner)
I got tired of doing this for my math homework all the time, and didn't find a suitable web calculator that I liked.
I consider myself no more than a novice, so this serves as both help and an opportunity for any programmers out there to offer constructive criticism. I often find that I've taken the least efficient route when I'm programming something, so feel free to tell me ways in which I could have simplified the program. Main Function Code:
double formula_main(double a, double b, double c, double negorpos) { double result; result = (-b + negorpos*(Math.Sqrt(Math.Pow(b, 2) - 4 * a * c))) / (2 * a); // Value To Be Returned return result; } Code:
// Declare Variables double a, b, c, res1, res2; // Execute // Ensure That The Input Boxes Hold Text if (txtA.Text != "" & txtB.Text != "" & txtC.Text != "") { // Assign User Input To Variables // C# Cannot Accept The String Value Like C++, You Must Convert It // With the Parse method of the Integer class a = int.Parse(txtA.Text); b = int.Parse(txtB.Text); c = int.Parse(txtC.Text); // Perform Function res1 = formula_main(a, b, c, 1); res2 = formula_main(a, b, c, -1); // Display Results txtZeros.AppendText(res1.ToString()); txtZeros.AppendText(Environment.NewLine + res2.ToString()); } I haven't added many accessories yet, besides a simple copy button to copy the results. I'm working on some validation in the TextBox, and for now, imaginary numbers are not supported and all radicals must be simplified before inputting them. Feel free to use.
__________________
Delta Force 2 Enhanced Modding Site, new and improved with forum. |
#2
|
||
|
i did this on my ti92 .. not the exact code but similar ..
great time saver lol
__________________
|
#3
|
||
|
True, it is an awesome time saver. I'm still having trouble with C# displaying imaginary numbers... that's the huge downside to the program now.
__________________
Delta Force 2 Enhanced Modding Site, new and improved with forum. |
#4
|
||
|
Looks good.
__________________
|
#5
|
||
|
well if you get an imaginary number as a result ... why do you care what it is? lol
__________________
|
#6
|
||
|
I think you also need to be handling exceptions that Int32.Parse throws.
__________________
|
#7
|
||||
|
Quote:
Quote:
__________________
Delta Force 2 Enhanced Modding Site, new and improved with forum. |
#8
|
||
|
Because the professor cares... lol.
__________________
Delta Force 2 Enhanced Modding Site, new and improved with forum. |
#9
|
||
|
then i don't even want to know what the hell kind of math you do lol
__________________
|
#10
|
||
|
If it is not in the math library, then you might have to program a short section of code that says "sqrt(-1) = j"
__________________
True forgiveness comes not from those who pull the trigger, but from those who have |
#11
|
||
|
Yea that might be a necessity. Are you a programmer yourself?
__________________
Delta Force 2 Enhanced Modding Site, new and improved with forum. |
#12
|
|||
|
Quote:
Most of the coding I do nowadays is either modding the .def files for DFx2 or assembly language for the HCS9S12. Also got a bit of experiance with the Ti-83
__________________
True forgiveness comes not from those who pull the trigger, but from those who have |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Atlantica Online Guides : Beginner Guide | kaninigyy | Gaming Talk | 0 | 01-21-2010 02:55 AM |
Perl beginner's guide | .::nØ燎ƒµEL::. | Web design and Programming | 6 | 12-11-2005 07:26 AM |
grade calculator | BOne | Web design and Programming | 2 | 12-10-2004 02:54 PM |
Sigs For Beginner | tennis_rocks | Sigs and Graphics | 15 | 07-23-2004 12:41 PM |
beginner stuff | katana*GFR* | Sigs and Graphics | 5 | 11-15-2003 07:29 PM |