How can I get this to work? I have the popup window where it pops up but I'm using Netbeans and the data I want in the popup box isn't in there.. it is in the netbeans runner thing. By the way don't judge the look of this code I except all criticism, but I'm only 13.
Code:
package FunctionSolver; import java.awt.Canvas; import java.util.Scanner; import javax.swing.JFrame; public class Main extends Canvas { public static final int WIDTH = 800; public static final int HEIGHT = 600; public static final String TITLE = "Linear Equation Solver"; public static void main(String[] args) { JFrame frame = new JFrame(); frame.pack(); frame.setTitle (TITLE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(WIDTH, HEIGHT); frame.setLocationRelativeTo(null); frame.setResizable(false); frame.setVisible(true); System.out.println("This solves both positive and negative functions."); System.out.println("This is a function solver(only linear equations)"); System.out.println("Max of three variables."); System.out.println("When righting fractions only use decimals like let's say you want 1/4 it needs to be .25 Thank you."); Scanner input; input = new Scanner(System.in); System.out.println("What Is Your Coefficient?"); double coef = input.nextDouble(); System.out.println("What is your constant?"); double constant = input.nextDouble(); System.out.println("What is your x variables?"); double a = input.nextDouble(); double b = input.nextDouble(); double c = input.nextDouble(); if(constant<=0) { System.out.println("FUNCTION: = f(x) = " + coef + "x" + constant ); System.out.println(); } else { System.out.println("FUNCTION: = f(x) = " + coef + "x + " + constant ); System.out.println(); } System.out.println("x Variables:"); System.out.println(); if(constant<=0) { System.out.println("function 1 -->f(x) = " + coef + "(" + a + ")" + constant); System.out.println(); System.out.println("function 2 -->f(x) = " + coef + "(" + b + ")" + constant); System.out.println(); System.out.println("function 3 -->f(x) = " + coef + "(" + c + ")" + constant); System.out.println(); } else { System.out.println("function 1 -->f(x) = " + coef + "(" + a + ")" + " + " + constant); System.out.println(); System.out.println("function 2 -->f(x) = " + coef + "(" + b + ")" + " + " + constant); System.out.println(); System.out.println("function 3 -->f(x) = " + coef + "(" + c + ")" + " + " + constant); System.out.println(); } double one; one = coef * a + constant; double two; two = coef * b + constant; double three; three = coef * c + constant; System.out.println("ANSWER:"); System.out.println(); System.out.println("Function 1 answer--> " + one); System.out.println(); System.out.println("Function 2 answer--> " + two); System.out.println(); System.out.println("Function 3 answer--> " + three); System.out.println(); System.out.println("Graph"); System.out.println(); System.out.println("Should look like this"); System.out.println("x | y"); System.out.println(); System.out.println(a +" | " + one); System.out.println(); System.out.println(b +" | " + two); System.out.println(); System.out.println(c +" | " + three); System.out.println(); System.out.println("The slope is: " + coef + "(remember the slope is understood over one.)"); System.out.println("The y-intercept is: " + constant); } }
Comment