Results 1 to 3 of 3
  1. #1
    kourai is offline Member
    Join Date
    Oct 2010
    Posts
    1
    Rep Power
    0

    Default quadratic equation, problems that i can't solve

    Java Code:
    import java.io.*;
    import javax.swing.JOptionPane;
    
    class RownanieKwadratowe
    {
    	//static float a, b, c, delta;
    	//static String pomocniczy;
    	//static double x, x1, x2;
    	
    	
    	public static void main(String[] args)
    	{
    		float a, b, c;
    		String pomocniczy;
    		double x, x1, x2, delta;
    		
    		pomocniczy=JOptionPane.showInputDialog(null, "Podaj wspolczynnik a równania kwadratowego: ");
    		a=Float.parseFloat(pomocniczy);
    		pomocniczy=JOptionPane.showInputDialog(null, "Podaj wspolczynnik b równania kwadratowego: ");
    		b=Float.parseFloat(pomocniczy);
    		pomocniczy=JOptionPane.showInputDialog(null, "Podaj wspolczynnik c równania kwadratowego: ");
    		c=Float.parseFloat(pomocniczy);
    		if (a!=0) 
    		{
    			delta=(b*b)-(4*a*c);
    			if (delta<0) System.out.println("Delta mniejsza od 0. Brak pierwiastkow rzeczywistych.");
    			if (delta==0) 
    			{
    				x=(-b)/(2*a);
    				System.out.println("Jeden pierwiastek podwojny x=" + x);
    				
    			}
    			if (delta>0)
    			{
    			x1=	(-b - Math.sqrt(delta))/2*a;
    			x2 =(-b + Math.sqrt(delta))/2*a;
    			System.out.println("Dwa pierwiastki rzeczywiste x1="+ x1 + " x2="+ x2);
    			}
    		}
    		else System.out.println("To nie rownanie kwadratowe. Nie mozna liczyc pierwiastkow.");
    	
    	System.exit(0);
    	}
    }
    here are the errors:
    1. Description Resource Path Location Type
    Syntax error on token "0", delete this token Zadanie2.java /Zadanie2/src line 47 Java Problem

    2. Description Resource Path Location Type
    Syntax error on token "Invalid Character", invalid AssignmentOperator Zadanie2.java /Zadanie2/src line 40 Java Problem

    3. Description Resource Path Location Type
    Syntax error on token(s), misplaced construct(s) Zadanie2.java /Zadanie2/src line 47 Java Problem

    4. Description Resource Path Location Type
    The left-hand side of an assignment must be a variable Zadanie2.java /Zadanie2/src line 40 Java Problem

    i don't know extacly what i did do wrong :/ can you help me? I'm new in java...that's my first program here...
    Last edited by kourai; 10-14-2010 at 11:49 AM.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by kourai View Post
    [code]
    here are the errors:
    1. Description Resource Path Location Type
    Syntax error on token "0", delete this token Zadanie2.java /Zadanie2/src line 47 Java Problem
    The source code you posted has only 46 lines ...

    kind regards,

    Jos

Similar Threads

  1. Please help me solve these Java Problems
    By saculellav in forum New To Java
    Replies: 9
    Last Post: 07-06-2014, 09:25 AM
  2. quadratic equation whith Rational class
    By adamrain in forum New To Java
    Replies: 8
    Last Post: 12-22-2009, 05:35 PM
  3. please I need your help to solve these problems
    By edge_5050@hotmail.com in forum New To Java
    Replies: 2
    Last Post: 12-17-2008, 08:34 PM
  4. Quadratic Equation
    By jpnym15 in forum New To Java
    Replies: 4
    Last Post: 11-12-2008, 03:29 AM
  5. Help with quadratic equation in java
    By paul in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 08:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •