import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.SWT;
import java.util.Scanner;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
class Quad {
public static void main(String args[]) {
Scanner key = new Scanner(System.in);
//need to make three screens to display user input
System.out.print("Enter a: ");double a = key.nextDouble();
System.out.print("Enter b: ");double b = key.nextDouble();
System.out.print("Enter c: ");double c = key.nextDouble();
System.out.println("");
double x = 0; x =(-b + Math.sqrt(b*b - (4 * a * c)))/ (2 * a);
double y = 0; y = (-b - Math.sqrt(b*b - (4 * a * c)))/ (2 * a);
//need to make two screens to display both outputs
System.out.println("x1= " + x);
System.out.println("x2= " + y);
}
}
public class QuadraticWindow {
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shlQuadraticApp = new Shell();
shlQuadraticApp.setSize(450, 300);
shlQuadraticApp.setText("Quadratic App");
Button btnCalculate = new Button(shlQuadraticApp, SWT.NONE);
btnCalculate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
btnCalculate.setBounds(183, 126, 68, 23);
btnCalculate.setText("Calculate");
Button button = new Button(shlQuadraticApp, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
});
button.setBounds(10, 89, 29, 23);
button.setText("1");
Button button_1 = new Button(shlQuadraticApp, SWT.NONE);
button_1.setText("4");
button_1.setBounds(10, 118, 29, 23);
Button button_2 = new Button(shlQuadraticApp, SWT.NONE);
button_2.setText("7");
button_2.setBounds(10, 147, 29, 23);
Button button_3 = new Button(shlQuadraticApp, SWT.NONE);
button_3.setText("8");
button_3.setBounds(45, 147, 29, 23);
Button button_4 = new Button(shlQuadraticApp, SWT.NONE);
button_4.setText("5");
button_4.setBounds(45, 118, 29, 23);
Button button_5 = new Button(shlQuadraticApp, SWT.NONE);
button_5.setText("2");
button_5.setBounds(45, 89, 29, 23);
Button button_6 = new Button(shlQuadraticApp, SWT.NONE);
button_6.setText("3");
button_6.setBounds(80, 89, 29, 23);
Button button_7 = new Button(shlQuadraticApp, SWT.NONE);
button_7.setText("6");
button_7.setBounds(80, 118, 29, 23);
Button button_8 = new Button(shlQuadraticApp, SWT.NONE);
button_8.setText("9");
button_8.setBounds(80, 147, 29, 23);
shlQuadraticApp.open();
shlQuadraticApp.layout();
while (!shlQuadraticApp.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}