Quadratic Formular Solver (Non-GUI)

Discussion in 'Programming General' started by SuF, Oct 13, 2008.

Quadratic Formular Solver (Non-GUI)
  1. Unread #1 - Oct 13, 2008 at 4:05 PM
  2. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    Quadratic Formular Solver (Non-GUI)

    I just made this better, because I have used it like 10,000 times for math class. :D. I hope you guys learn something. :p

    Code:
    package suf;
    
    import java.util.*;
    
    public class QuadraticSolver 
    {
    	static boolean useAgain = true;
    	static Scanner s = new Scanner(System.in);
    	static boolean validInput = true;
    
    	public static void main(String[] args)
    	{
    		System.out.println("Welcome to SuF's Quadtratic Formula Solver!");
    		System.out.println("Remeber your negivtive signs!");
    
    		while (useAgain) 
    		{
    			quadraticFormula();
    			System.out.print("Would you like to use this program again? ('Y' or 'N'):");
    			do 
    			{
    				String answer = s.next();
    				validInput = true;
    				if (answer.equalsIgnoreCase("N"))
    					useAgain = false;
    				else if (answer.equalsIgnoreCase("Y"))
    					;
    				else 
    				{
    					validInput = false;
    					System.out.println("Please Enter 'Y' or 'N'");
    				}
    
    			} while (!validInput);
    
    		}
    		System.out.println("\n" + "Thank you for using SuF's Quadtratic Formula Solver!");
    	}
    
    	public static void quadraticFormula() 
    	{
    		double a = getInput("Enter A:");
    		double b = getInput("Enter B:");
    		double c = getInput("Enter C:");
    		double d = Math.sqrt((b * b) - (4 * a * c));
    		System.out.println("Answer 1: " + (-b + d) / (2 * a) + "\n" + "Answer 2: " + (-b - d) / (2 * a));
    	}
    
    	public static double getInput(String output) 
    	{
    		while (true) 
    		{
    			try 
    			{
    			System.out.print(output);
    			return s.nextDouble();
    			} 
    			catch (InputMismatchException e) 
    			{
    				s.next();
    			}
    		}
    
    	}
    
    }
     
  3. Unread #2 - Oct 13, 2008 at 4:12 PM
  4. Billyy
    Joined:
    Nov 3, 2007
    Posts:
    2,842
    Referrals:
    6
    Sythe Gold:
    0

    Billyy Guru of Ganja
    Banned

    Quadratic Formular Solver (Non-GUI)

    I have a QF program on my TI-84+ Silver Edition. :D
     
  5. Unread #3 - Oct 13, 2008 at 8:24 PM
  6. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    Quadratic Formular Solver (Non-GUI)

    I just have chemistry test answers on mine. :D
     
  7. Unread #4 - Oct 21, 2008 at 3:45 PM
  8. GreatKhan
    Referrals:
    0

    GreatKhan Guest

    Quadratic Formular Solver (Non-GUI)

    Best way to hide formulas on a calc is through pics ^^ (2nd+prog.. u can figure it out from there).. teachers usually only check for programs and its pretty fast to load a pic ^^
     
  9. Unread #5 - Oct 21, 2008 at 8:19 PM
  10. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    Quadratic Formular Solver (Non-GUI)

    Our teachers don't check our calcs for anything... lul
     
  11. Unread #6 - Nov 5, 2008 at 10:40 PM
  12. Dreadsthegreat
    Joined:
    Apr 19, 2006
    Posts:
    119
    Referrals:
    0
    Sythe Gold:
    4

    Dreadsthegreat Active Member

    Quadratic Formular Solver (Non-GUI)

    its kinda sad, there are calculators with dictionary words isnide them
     
  13. Unread #7 - Nov 6, 2008 at 2:37 AM
  14. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Quadratic Formular Solver (Non-GUI)

    And? My calculator has Doom on it.
     
  15. Unread #8 - Nov 6, 2008 at 6:41 AM
  16. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    Quadratic Formular Solver (Non-GUI)

    Well, thats fucking unfair! :(
     
< Make your own Swiftkit/EliteSwitch? | Trackbar control to change richtextbox font size? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site