• Log in or sign up for an account here: https://www.sythe.org/login

Quadratic Formular Solver (Non-GUI)

SuF

Legend

Pirate
Retired Global Moderator
Joined
Jan 21, 2007
Sythe Gold
1,234
Messages
14,211
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
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 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
I just have chemistry test answers on mine. :D
 
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 ^^
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
Our teachers don't check our calcs for anything... lul
 
Member of the Month Winner
Sythe's 10th Anniversary
Runescape Gamblingrunescape gambling
Back
Top