|
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. |
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 |